on master help sign in
Add some type hints for JSON library.
76aab32evancz
elm/src/Types/Hints.hs+13−1
@@ -80,6 +80,18 @@ polyCasts =
80 , "castListToJSArray" -:: listOf a ==> jsArray a
80 , "castListToJSArray" -:: listOf a ==> jsArray a
81 ]
81 ]
82
82
83+json =
84+ [ "JsonString" -: string ==> jsonValue
85+ , "JsonBool" -: bool ==> jsonValue
86+ , "JsonNull" -: jsonValue
87+ , "JsonArray" -: listOf jsonValue ==> jsonValue
88+ , "JsonObject" -: jsonObject ==> jsonValue
89+ , numScheme (\n -> n ==> jsonValue) "JsonNumber"
90+ , "toPrettyString" -: string ==> jsonObject ==> string
91+ , "toPrettyJSString" -: string ==> jsonObject ==> jsString
92+ , "toJSString" -: jsonObject ==> jsString
93+ ]
94+
83
95
84-------- Signals --------
96-------- Signals --------
85
97
@@ -219,5 +231,5 @@ lists =
219hints =
231hints =
220 concat [ funcs, lists, signals, math, bools, str2elem, textAttrs
232 concat [ funcs, lists, signals, math, bools, str2elem, textAttrs
221 , elements, directions, colors, lineTypes, shapes
233 , elements, directions, colors, lineTypes, shapes
222− , concreteSignals, casts, polyCasts
234+ , concreteSignals, casts, polyCasts, json
223 ]
235 ]
elm/src/Types/Types.hs+2
@@ -58,6 +58,8 @@ jsString = tipe "JSString"
58jsElement = tipe "JSElement"
58jsElement = tipe "JSElement"
59jsArray t = ADT "JSArray" [t]
59jsArray t = ADT "JSArray" [t]
60jsTuple ts = ADT ("JSTuple" ++ show (length ts)) ts
60jsTuple ts = ADT ("JSTuple" ++ show (length ts)) ts
61+jsonValue = tipe "JsonValue"
62+jsonObject = tipe "JsonObject"
61
63
62infixr ==>
64infixr ==>
63t1 ==> t2 = LambdaT t1 t2
65t1 ==> t2 = LambdaT t1 t2