on develop help sign in
Ensuring parameters are correctly filtered for required/defaulted
b87b854Brendan Hay
gen/src/Gen/Syntax.hs+3−3
@@ -461,7 +461,7 @@ ctorDecl n p rs = sfun noLoc c ps (UnGuardedRhs rhs) noBinds
461 | otherwise = RecConstr (UnQual d) $
461 | otherwise = RecConstr (UnQual d) $
462 map (uncurry (fieldUpdate p)) (Map.toList rs)
462 map (uncurry (fieldUpdate p)) (Map.toList rs)
463
463
464− ps = map (pname p) . Map.keys $ Map.filter required rs
464+ ps = map (pname p) . Map.keys $ Map.filter parameter rs
465
465
466fieldUpdate :: Prefix -> Local -> Solved -> FieldUpdate
466fieldUpdate :: Prefix -> Local -> Solved -> FieldUpdate
467fieldUpdate p l s = FieldUpdate (UnQual (fname p l)) rhs
467fieldUpdate p l s = FieldUpdate (UnQual (fname p l)) rhs
@@ -469,7 +469,7 @@ fieldUpdate p l s = FieldUpdate (UnQual (fname p l)) rhs
469 rhs | Just x <- def s, s ^. iRepeated = listE [x]
469 rhs | Just x <- def s, s ^. iRepeated = listE [x]
470 | Just x <- def s = x
470 | Just x <- def s = x
471 | Just x <- iso (_type s) = infixApp x "#" v
471 | Just x <- iso (_type s) = infixApp x "#" v
472− | required s = v
472+ | parameter s = v
473 | otherwise = var (name "Nothing")
473 | otherwise = var (name "Nothing")
474
474
475 v = var (pname p l)
475 v = var (pname p l)
@@ -491,7 +491,7 @@ lensDecl p l s = sfun noLoc (lname p l) [] (UnGuardedRhs rhs) noBinds
491 (RecUpdate (var "s") [FieldUpdate (UnQual f) (var "a")])))
491 (RecUpdate (var "s") [FieldUpdate (UnQual f) (var "a")])))
492
492
493parameters :: [Solved] -> [Type]
493parameters :: [Solved] -> [Type]
494−parameters = map (externalType . _type) . filter required
494+parameters = map (externalType . _type) . filter parameter
495
495
496def :: Solved -> Maybe Exp
496def :: Solved -> Maybe Exp
497def s
497def s