on master help sign in
Fix compilation error in Hints.hs, and correct a character escaping bug in the JS output.
1610b99evancz
elm/src/Gen/CompileToJS.hs+7−1
@@ -42,8 +42,12 @@ tryBlock escapees names e =
42 , "};}"
42 , "};}"
43 ]
43 ]
44 where msg | escapees /= [] = concat [ "<br/><br/>The problem may stem from an improper usage of:<br/>"
44 where msg | escapees /= [] = concat [ "<br/><br/>The problem may stem from an improper usage of:<br/>"
45− , intercalate ", " escapees ]
45+ , intercalate ", " $ map (concatMap escape) escapees ]
46 | otherwise = ""
46 | otherwise = ""
47+ escape '\'' = "\\'"
48+ escape '"' = "\\\""
49+ escape c = [c]
50+
47
51
48jsModule (escapees, Module names exports imports stmts) =
52jsModule (escapees, Module names exports imports stmts) =
49 tryBlock escapees (tail modNames) $ concat
53 tryBlock escapees (tail modNames) $ concat
@@ -215,6 +219,8 @@ binop (o:p) e1 e2
215 ">" -> "(compare(" ++ e1 ++ ")(" ++ e2 ++ ")[0] === 'GT')"
219 ">" -> "(compare(" ++ e1 ++ ")(" ++ e2 ++ ")[0] === 'GT')"
216 "<=" -> "function() { var ord = compare(" ++ e1 ++ ")(" ++ e2 ++ ")[0]; return ord === 'LT' || ord === 'EQ'; }()"
220 "<=" -> "function() { var ord = compare(" ++ e1 ++ ")(" ++ e2 ++ ")[0]; return ord === 'LT' || ord === 'EQ'; }()"
217 ">=" -> "function() { var ord = compare(" ++ e1 ++ ")(" ++ e2 ++ ")[0]; return ord === 'GT' || ord === 'EQ'; }()"
221 ">=" -> "function() { var ord = compare(" ++ e1 ++ ")(" ++ e2 ++ ")[0]; return ord === 'GT' || ord === 'EQ'; }()"
222+ ">>>" -> "composeAuto(" ++ e1 ++ ")(" ++ e2 ++ ")"
223+ "<<<" -> "composeAuto(" ++ e2 ++ ")(" ++ e1 ++ ")"
218 _ -> parens (e1 ++ (o:p) ++ e2)
224 _ -> parens (e1 ++ (o:p) ++ e2)
219
225
220append e1 e2 = "Value.append" ++ parens (e1 ++ "," ++ e2)
226append e1 e2 = "Value.append" ++ parens (e1 ++ "," ++ e2)
elm/src/Types/Hints.hs+10−11
@@ -146,14 +146,14 @@ signals =
146 ]
146 ]
147
147
148http =
148http =
149− [ "send" -:: signalOf (request a) -> signalOf (response string)
149+ [ "send" -:: signalOf (request a) ==> signalOf (response string)
150− , "sendGet" -:: signalOf string -> signalOf (response string)
150+ , "sendGet" -:: signalOf string ==> signalOf (response string)
151 , "get" -: string ==> request string
151 , "get" -: string ==> request string
152 , "post" -: string ==> string ==> request string
152 , "post" -: string ==> string ==> request string
153 , "request" -: string ==> string ==> string ==> listOf (pairOf string) ==> request string
153 , "request" -: string ==> string ==> string ==> listOf (pairOf string) ==> request string
154 , "Waiting" -:: response a
154 , "Waiting" -:: response a
155 , "Failure" -:: int ==> string ==> response a
155 , "Failure" -:: int ==> string ==> response a
156− , "Success" -:: a -> response a ]
156+ , "Success" -:: a ==> response a ]
157 where request t = ADT "Request" [t]
157 where request t = ADT "Request" [t]
158 response t = ADT "Response" [t]
158 response t = ADT "Response" [t]
159
159
@@ -211,14 +211,13 @@ bools =
211 , Forall [0,1] [ Context "`compare'" $ VarT 0 :<: comparable ] (VarT 0 ==> VarT 0 ==> VarT 1) )
211 , Forall [0,1] [ Context "`compare'" $ VarT 0 :<: comparable ] (VarT 0 ==> VarT 0 ==> VarT 1) )
212 ]
212 ]
213
213
214−chars =
214+chars = classify ++ convert1 ++ convert2
215− [ hasType (char ==> bool)
215+ where classify = hasType (char ==> bool)
216− ["isDigit","isOctDigit","isHexDigit","isUpper","isLower"]
216+ ["isDigit","isOctDigit","isHexDigit","isUpper","isLower"]
217− , hasType (char ==> char)
217+ convert1 = hasType (char ==> char)
218− ["toUpper","toLower","toLocaleUpper","toLocaleLower"]
218+ ["toUpper","toLower","toLocaleUpper","toLocaleLower"]
219− , "toCode" -: char ==> int
220− , "fromCode" -: int ==> char
219+ convert2 = [ "toCode" -: char ==> int, "fromCode" -: int ==> char ]
221− ]
220+
222
221
223-------- Polymorphic Functions --------
222-------- Polymorphic Functions --------
224
223