@@ -49,9 +49,8 @@ portTypes :: Alias.Rules -> E.LExpr -> Either [P.Doc] ()
4949portTypes rules expr =
5050 const () <$> Expr.checkPorts (check In) (check Out) expr
5151 where
52− check = isValid False False
53− isValid seenFunc seenSignal direction name tipe =
54− let valid = isValid seenFunc seenSignal direction name in
52+ check = isValid True False False
53+ isValid isTopLevel seenFunc seenSignal direction name tipe =
5554 case tipe of
5655 T.Data ctor ts
5756 | isJs ctor || isElm ctor -> mapM_ valid ts
@@ -66,7 +65,8 @@ portTypes rules expr =
6665 Out | seenFunc -> err "higher-order functions"
6766 | seenSignal -> err "signals that contain functions"
6867 | otherwise ->
69− mapM_ (isValid True seenSignal direction name) (T.collectLambdas tipe)
68+ forM_ (T.collectLambdas tipe)
69+ (isValid' True seenSignal direction name)
7070
7171 T.Record _ (Just _) -> err "extended records with free type variables"
7272
@@ -74,6 +74,9 @@ portTypes rules expr =
7474 mapM_ (\(k,v) -> (,) k <$> valid v) fields
7575
7676 where
77+ isValid' = isValid False
78+ valid = isValid' seenFunc seenSignal direction name
79+
7780 isJs ctor =
7881 List.isPrefixOf "JavaScript." ctor
7982 && length (filter (=='.') ctor) == 1
@@ -85,7 +88,8 @@ portTypes rules expr =
8588 handleSignal ts
8689 | seenFunc = err "functions that involve signals"
8790 | seenSignal = err "signals-of-signals"
88− | otherwise = mapM_ (isValid seenFunc True direction name) ts
91+ | isTopLevel = mapM_ (isValid' seenFunc True direction name) ts
92+ | otherwise = err "a signal within a data stucture"
8993
9094 dir inMsg outMsg = case direction of { In -> inMsg ; Out -> outMsg }
9195 txt = P.text . concat