@@ -26,13 +26,19 @@ indent = concatMap f
2626 f c = [c]
2727
2828parens s = "(" ++ s ++ ")"
29−quoted s = "'" ++ s ++ "'"
3029braces s = "{" ++ s ++ "}"
3130jsList ss = "["++ intercalate "," ss ++"]"
3231jsFunc args body = "function(" ++ args ++ "){" ++ indent body ++ "}"
3332assign x e = "\nvar " ++ x ++ "=" ++ e ++ ";"
3433ret e = "\nreturn "++ e ++";"
3534iff a b c = a ++ "?" ++ b ++ ":" ++ c
35+quoted s = "'" ++ concatMap f s ++ "'"
36+ where f '\n' = "\\n"
37+ f '\'' = "\\'"
38+ f '\t' = "\\t"
39+ f '\"' = "\\\""
40+ f '\\' = "\\\\"
41+ f c = [c]
3642
3743mainEquals s = globalAssign "Elm.main" (jsFunc "" (ret s))
3844globalAssign m s = "\n" ++ m ++ "=" ++ s ++ ";"