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