on master help sign in
Add some type hints for JSON library.
commit76aab32ef6a5cf8043e0d858c78bbc175ca6e6a6 authorevancz <info@elm-lang.org> dateSat 28 Jul 2012, 22:59 (14 years ago) parentf39142d
2 files changed+15−1
elm/src/Types/Hints.hs+13−1 elm/src/Types/Types.hs+2
elm/src/Types/Hints.hs+13−1
@@ -80,6 +80,18 @@ polyCasts =
8080 , "castListToJSArray" -:: listOf a ==> jsArray a
8181 ]
8282
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+
8395
8496-------- Signals --------
8597
@@ -219,5 +231,5 @@ lists =
219231hints =
220232 concat [ funcs, lists, signals, math, bools, str2elem, textAttrs
221233 , elements, directions, colors, lineTypes, shapes
222− , concreteSignals, casts, polyCasts
234+ , concreteSignals, casts, polyCasts, json
223235 ]
elm/src/Types/Types.hs+2
@@ -58,6 +58,8 @@ jsString = tipe "JSString"
5858jsElement = tipe "JSElement"
5959jsArray t = ADT "JSArray" [t]
6060jsTuple ts = ADT ("JSTuple" ++ show (length ts)) ts
61+jsonValue = tipe "JsonValue"
62+jsonObject = tipe "JsonObject"
6163
6264infixr ==>
6365t1 ==> t2 = LambdaT t1 t2