on master help sign in
Update changelog and error messages for type aliases in port types
52ecd6bEvan Czaplicki
changelog.md+1
@@ -3,6 +3,7 @@
3
3
4#### Improvements:
4#### Improvements:
5
5
6+ * Type aliases are allowed in port types
6 * Error on ambiguious use of imported variables
7 * Error on ambiguious use of imported variables
7 * Higher kinded polymorphism (a.k.a. higher-order types)
8 * Higher kinded polymorphism (a.k.a. higher-order types)
8 * Many bug fixes for importing types
9 * Many bug fixes for importing types
compiler/Type/ExtraChecks.hs+3−9
@@ -65,7 +65,7 @@ portTypes expr =
65 ST.Type v
65 ST.Type v
66 | V.isJson v -> return ()
66 | V.isJson v -> return ()
67 | V.isPrimitive v -> return ()
67 | V.isPrimitive v -> return ()
68− | otherwise -> err' True "an unsupported type"
68+ | otherwise -> err "an unsupported type"
69
69
70 ST.App t [] -> valid t
70 ST.App t [] -> valid t
71
71
@@ -78,7 +78,7 @@ portTypes expr =
78 ST.App (ST.Type v) ts
78 ST.App (ST.Type v) ts
79 | V.isTuple v -> mapM_ valid ts
79 | V.isTuple v -> mapM_ valid ts
80
80
81− ST.App _ _ -> err' True "an unsupported type"
81+ ST.App _ _ -> err "an unsupported type"
82
82
83 ST.Var _ -> err "free type variables"
83 ST.Var _ -> err "free type variables"
84
84
@@ -109,8 +109,7 @@ portTypes expr =
109 dir inMsg outMsg = case direction of { In -> inMsg ; Out -> outMsg }
109 dir inMsg outMsg = case direction of { In -> inMsg ; Out -> outMsg }
110 txt = P.text . concat
110 txt = P.text . concat
111
111
112− err = err' False
112+ err kind =
113− err' couldBeAlias kind =
114 throw $
113 throw $
115 [ txt [ "Type Error: the value ", dir "coming in" "sent out"
114 [ txt [ "Type Error: the value ", dir "coming in" "sent out"
116 , " through port '", name, "' is invalid." ]
115 , " through port '", name, "' is invalid." ]
@@ -119,11 +118,6 @@ portTypes expr =
119 , txt [ "Acceptable values for ", dir "incoming" "outgoing", " ports include:" ]
118 , txt [ "Acceptable values for ", dir "incoming" "outgoing", " ports include:" ]
120 , txt [ " Ints, Floats, Bools, Strings, Maybes, Lists, Arrays, Tuples," ]
119 , txt [ " Ints, Floats, Bools, Strings, Maybes, Lists, Arrays, Tuples," ]
121 , txt [ " Json.Values, ", dir "" "first-order functions, ", "and concrete records." ]
120 , txt [ " Json.Values, ", dir "" "first-order functions, ", "and concrete records." ]
122− ] ++ if couldBeAlias then aliasWarning else []
123−
124− aliasWarning =
125− [ txt [ "\nType aliases are not expanded for this check (yet) so you need to do that" ]
126− , txt [ "manually for now (e.g. {x:Int,y:Int} instead of a type alias of that type)." ]
127 ]
121 ]
128
122
129occurs :: (String, TT.Variable) -> StateT TS.SolverState IO ()
123occurs :: (String, TT.Variable) -> StateT TS.SolverState IO ()