on master help sign in
Rename JSIntNumber to JSInt and use (<|)
e7a4551Evan Czaplicki
src/Generate/JavaScript/Port.hs+6−6
@@ -27,7 +27,7 @@ task name expr portType =
27
27
28data JSType
28data JSType
29 = JSNumber
29 = JSNumber
30− | JSIntNumber
30+ | JSInt
31 | JSBoolean
31 | JSBoolean
32 | JSString
32 | JSString
33 | JSArray
33 | JSArray
@@ -38,7 +38,7 @@ typeToString :: JSType -> String
38typeToString tipe =
38typeToString tipe =
39 case tipe of
39 case tipe of
40 JSNumber -> "a number"
40 JSNumber -> "a number"
41− JSIntNumber -> "an integer"
41+ JSInt -> "an integer"
42 JSBoolean -> "a boolean (true or false)"
42 JSBoolean -> "a boolean (true or false)"
43 JSString -> "a string"
43 JSString -> "a string"
44 JSArray -> "an array"
44 JSArray -> "an array"
@@ -84,7 +84,7 @@ check x jsType continue =
84 checks =
84 checks =
85 case jsType of
85 case jsType of
86 JSNumber -> [typeof "number"]
86 JSNumber -> [typeof "number"]
87− JSIntNumber ->
87+ JSInt ->
88 [jsFold OpLAnd (typeof "number" : intChecks)]
88 [jsFold OpLAnd (typeof "number" : intChecks)]
89 JSBoolean -> [typeof "boolean"]
89 JSBoolean -> [typeof "boolean"]
90 JSString -> [typeof "string", instanceof "String"]
90 JSString -> [typeof "string", instanceof "String"]
@@ -93,8 +93,8 @@ check x jsType continue =
93 [jsFold OpLAnd (typeof "object" : map member fields)]
93 [jsFold OpLAnd (typeof "object" : map member fields)]
94
94
95 intChecks =
95 intChecks =
96− [ \x -> (ref "isFinite") `call` [x]
96+ [ \x -> ref "isFinite" <| x
97− , \x -> equal (obj ["Math","floor"] `call` [x]) x
97+ , \x -> equal (obj ["Math","floor"] <| x) x
98 ]
98 ]
99
99
100
100
@@ -137,7 +137,7 @@ toType tipe x =
137
137
138 T.Type (Var.Canonical Var.BuiltIn name)
138 T.Type (Var.Canonical Var.BuiltIn name)
139 | name == "Float" -> from JSNumber
139 | name == "Float" -> from JSNumber
140− | name == "Int" -> from JSIntNumber
140+ | name == "Int" -> from JSInt
141 | name == "Bool" -> from JSBoolean
141 | name == "Bool" -> from JSBoolean
142 | name == "String" -> from JSString
142 | name == "String" -> from JSString
143 where
143 where