Skip to content

Commit

Permalink
Ensuring parameters are correctly filtered for required/defaulted
Browse files Browse the repository at this point in the history
Fixes #10.
  • Loading branch information
brendanhay committed Oct 27, 2015
1 parent 120e8e3 commit b87b854
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions gen/src/Gen/Syntax.hs
Original file line number Diff line number Diff line change
Expand Up @@ -461,15 +461,15 @@ ctorDecl n p rs = sfun noLoc c ps (UnGuardedRhs rhs) noBinds
| otherwise = RecConstr (UnQual d) $
map (uncurry (fieldUpdate p)) (Map.toList rs)

ps = map (pname p) . Map.keys $ Map.filter required rs
ps = map (pname p) . Map.keys $ Map.filter parameter rs

fieldUpdate :: Prefix -> Local -> Solved -> FieldUpdate
fieldUpdate p l s = FieldUpdate (UnQual (fname p l)) rhs
where
rhs | Just x <- def s, s ^. iRepeated = listE [x]
| Just x <- def s = x
| Just x <- iso (_type s) = infixApp x "#" v
| required s = v
| parameter s = v
| otherwise = var (name "Nothing")

v = var (pname p l)
Expand All @@ -491,7 +491,7 @@ lensDecl p l s = sfun noLoc (lname p l) [] (UnGuardedRhs rhs) noBinds
(RecUpdate (var "s") [FieldUpdate (UnQual f) (var "a")])))

parameters :: [Solved] -> [Type]
parameters = map (externalType . _type) . filter required
parameters = map (externalType . _type) . filter parameter

def :: Solved -> Maybe Exp
def s
Expand Down

0 comments on commit b87b854

Please sign in to comment.