on master help sign in
Fix compilation error in Hints.hs, and correct a character escaping bug in the JS output.
commit1610b99b4e77e5fcb3eaceec05c0d30e377233d0 authorevancz <info@elm-lang.org> dateSat 6 Oct 2012, 23:13 (14 years ago) parente3ac170
2 files changed+17−12
elm/src/Gen/CompileToJS.hs+7−1 elm/src/Types/Hints.hs+10−11
elm/src/Gen/CompileToJS.hs+7−1
@@ -42,8 +42,12 @@ tryBlock escapees names e =
4242 , "};}"
4343 ]
4444 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 ]
4646 | otherwise = ""
47+ escape '\'' = "\\'"
48+ escape '"' = "\\\""
49+ escape c = [c]
50+
4751
4852jsModule (escapees, Module names exports imports stmts) =
4953 tryBlock escapees (tail modNames) $ concat
@@ -215,6 +219,8 @@ binop (o:p) e1 e2
215219 ">" -> "(compare(" ++ e1 ++ ")(" ++ e2 ++ ")[0] === 'GT')"
216220 "<=" -> "function() { var ord = compare(" ++ e1 ++ ")(" ++ e2 ++ ")[0]; return ord === 'LT' || ord === 'EQ'; }()"
217221 ">=" -> "function() { var ord = compare(" ++ e1 ++ ")(" ++ e2 ++ ")[0]; return ord === 'GT' || ord === 'EQ'; }()"
222+ ">>>" -> "composeAuto(" ++ e1 ++ ")(" ++ e2 ++ ")"
223+ "<<<" -> "composeAuto(" ++ e2 ++ ")(" ++ e1 ++ ")"
218224 _ -> parens (e1 ++ (o:p) ++ e2)
219225
220226append e1 e2 = "Value.append" ++ parens (e1 ++ "," ++ e2)
elm/src/Types/Hints.hs+10−11
@@ -146,14 +146,14 @@ signals =
146146 ]
147147
148148http =
149− [ "send" -:: signalOf (request a) -> signalOf (response string)
150− , "sendGet" -:: signalOf string -> signalOf (response string)
149+ [ "send" -:: signalOf (request a) ==> signalOf (response string)
150+ , "sendGet" -:: signalOf string ==> signalOf (response string)
151151 , "get" -: string ==> request string
152152 , "post" -: string ==> string ==> request string
153153 , "request" -: string ==> string ==> string ==> listOf (pairOf string) ==> request string
154154 , "Waiting" -:: response a
155155 , "Failure" -:: int ==> string ==> response a
156− , "Success" -:: a -> response a ]
156+ , "Success" -:: a ==> response a ]
157157 where request t = ADT "Request" [t]
158158 response t = ADT "Response" [t]
159159
@@ -211,14 +211,13 @@ bools =
211211 , Forall [0,1] [ Context "`compare'" $ VarT 0 :<: comparable ] (VarT 0 ==> VarT 0 ==> VarT 1) )
212212 ]
213213
214−chars =
215− [ hasType (char ==> bool)
216− ["isDigit","isOctDigit","isHexDigit","isUpper","isLower"]
217− , hasType (char ==> char)
218− ["toUpper","toLower","toLocaleUpper","toLocaleLower"]
219− , "toCode" -: char ==> int
220− , "fromCode" -: int ==> char
221− ]
214+chars = classify ++ convert1 ++ convert2
215+ where classify = hasType (char ==> bool)
216+ ["isDigit","isOctDigit","isHexDigit","isUpper","isLower"]
217+ convert1 = hasType (char ==> char)
218+ ["toUpper","toLower","toLocaleUpper","toLocaleLower"]
219+ convert2 = [ "toCode" -: char ==> int, "fromCode" -: int ==> char ]
220+
222221
223222-------- Polymorphic Functions --------
224223