@@ -21,21 +21,20 @@ extraChecks :: Alias.Rules -> TS.Env -> IO (Either [P.Doc] (Map.Map String Type)
21extraChecks rules env =
21extraChecks rules env =
22 mainCheck rules <$> Traverse.traverse toSrcType env
22 mainCheck rules <$> Traverse.traverse toSrcType env
24−mainCheck :: Alias.Rules -> (Map.Map String Type) -> Either [P.Doc] (Map.Map String Type)
24+mainCheck :: Alias.Rules -> Map.Map String Type -> Either [P.Doc] (Map.Map String Type)
25mainCheck rules env =
25mainCheck rules env =
26− let acceptable = ["Graphics.Element.Element","Signal.Signal Graphics.Element.Element"] in
27 case Map.lookup "main" env of
26 case Map.lookup "main" env of
28 Nothing -> Right env
27 Nothing -> Right env
29− Just tipe
28+ Just mainType
30− | P.render (pretty (Alias.canonicalRealias (fst rules) tipe)) `elem` acceptable ->
31− Right env
29+ | tipe `elem` acceptable -> Right env
32− | otherwise ->
30+ | otherwise -> Left [ P.vcat err ]
33− Left [ P.vcat [ P.text "Type Error:"
31+ where
32+ acceptable = ["Graphics.Element.Element","Signal.Signal Graphics.Element.Element"]
33+ tipe = P.render . pretty $ Alias.canonicalRealias (fst rules) mainType
34− , P.text "Bad type for 'main'. It must have type Element or a (Signal Element)"
34+ err = [ P.text "Type Error: 'main' must have type Element or (Signal Element)."
35− , P.text "Instead 'main' has type:\n"
35+ , P.text "Instead 'main' has type:\n"
36− , P.nest 4 . pretty $ Alias.realias rules tipe
36+ , P.nest 4 . pretty $ Alias.realias rules mainType
37− , P.text " " ]
37+ , P.text " " ]
40occursCheck :: (String, Variable) -> StateT TS.SolverState IO ()
39occursCheck :: (String, Variable) -> StateT TS.SolverState IO ()
41occursCheck (name, variable) =
40occursCheck (name, variable) =