@@ -94,7 +94,9 @@ ffi code args = let parsed = ffiParse code in
9494 ffiParse ('%':'%':ss) = FFICode '%' : ffiParse ss
9595 ffiParse ('%':s:ss)
9696 | isDigit s =
97− FFIArg (read $ s : takeWhile isDigit ss) : ffiParse (dropWhile isDigit ss)
97+ FFIArg (
98+ read $ s : takeWhile isDigit ss
99+ ) : ffiParse (dropWhile isDigit ss)
98100 | otherwise =
99101 [FFIError "FFI - Invalid positional argument"]
100102 ffiParse (s:ss) = FFICode s : ffiParse ss
@@ -110,7 +112,9 @@ ffi code args = let parsed = ffiParse code in
110112 renderFFI [] _ = ""
111113 renderFFI (FFICode c : fs) args = c `T.cons` renderFFI fs args
112114 renderFFI (FFIArg i : fs) args
113− | i < length args && i >= 0 = T.pack (args !! i) `T.append` renderFFI fs args
115+ | i < length args && i >= 0 =
116+ T.pack (args !! i)
117+ `T.append` renderFFI fs args
114118 | otherwise = error "FFI - Argument index out of bounds"
115119
116120compileJS :: JS -> T.Text
@@ -120,7 +124,10 @@ compileJS' :: Int -> JS -> T.Text
120124compileJS' indent JSNoop = ""
121125
122126compileJS' indent (JSAnnotation annotation js) =
123− "/** @" `T.append` T.pack (show annotation) `T.append` " */\n" `T.append` compileJS' indent js
127+ "/** @"
128+ `T.append` T.pack (show annotation)
129+ `T.append` " */\n"
130+ `T.append` compileJS' indent js
124131
125132compileJS' indent (JSFFI raw args) =
126133 ffi raw (map (T.unpack . compileJS' indent) args)
@@ -166,13 +173,21 @@ compileJS' indent (JSApp lhs rhs)
166173 args = T.intercalate "," $ map (compileJS' 0) rhs
167174
168175compileJS' indent (JSNew name args) =
169− "new " `T.append` T.pack name `T.append` "(" `T.append` T.intercalate "," (map (compileJS' 0) args) `T.append` ")"
176+ "new "
177+ `T.append` T.pack name
178+ `T.append` "("
179+ `T.append` T.intercalate "," (map (compileJS' 0) args)
180+ `T.append` ")"
170181
171182compileJS' indent (JSError exc) =
172183 "throw new Error(\"" `T.append` T.pack exc `T.append` "\")"
173184
174185compileJS' indent (JSBinOp op lhs rhs) =
175− compileJS' indent lhs `T.append` " " `T.append` T.pack op `T.append` " " `T.append` compileJS' indent rhs
186+ compileJS' indent lhs
187+ `T.append` " "
188+ `T.append` T.pack op
189+ `T.append` " "
190+ `T.append` compileJS' indent rhs
176191
177192compileJS' indent (JSPreOp op val) =
178193 T.pack op `T.append` compileJS' indent val
@@ -212,19 +227,29 @@ compileJS' indent (JSNum num)
212227 | JSInteger JSBigZero <- num = T.pack "i$ZERO"
213228 | JSInteger JSBigOne <- num = T.pack "i$ONE"
214229 | JSInteger (JSBigInt i) <- num = T.pack (show i)
215− | JSInteger (JSBigIntExpr e) <- num = "i$bigInt(" `T.append` compileJS' indent e `T.append` ")"
230+ | JSInteger (JSBigIntExpr e) <- num =
231+ "i$bigInt(" `T.append` compileJS' indent e `T.append` ")"
216232
217233compileJS' indent (JSAssign lhs rhs) =
218234 compileJS' indent lhs `T.append` " = " `T.append` compileJS' indent rhs
219235
220236compileJS' 0 (JSAlloc name (Just val@(JSNew _ _))) =
221− "var " `T.append` T.pack name `T.append` " = " `T.append` compileJS' 0 val `T.append` ";\n"
237+ "var "
238+ `T.append` T.pack name
239+ `T.append` " = "
240+ `T.append` compileJS' 0 val
241+ `T.append` ";\n"
222242
223243compileJS' indent (JSAlloc name val) =
224− "var " `T.append` T.pack name `T.append` maybe "" ((" = " `T.append`) . compileJS' indent) val
244+ "var "
245+ `T.append` T.pack name
246+ `T.append` maybe "" ((" = " `T.append`) . compileJS' indent) val
225247
226248compileJS' indent (JSIndex lhs rhs) =
227− compileJS' indent lhs `T.append` "[" `T.append` compileJS' indent rhs `T.append` "]"
249+ compileJS' indent lhs
250+ `T.append` "["
251+ `T.append` compileJS' indent rhs
252+ `T.append` "]"
228253
229254compileJS' indent (JSCond branches) =
230255 T.intercalate " else " $ map createIfBlock branches
@@ -243,13 +268,20 @@ compileJS' indent (JSCond branches) =
243268 `T.append` "\n" `T.append` T.replicate indent " " `T.append` "}"
244269 createIfBlock (cond, e) =
245270 "if (" `T.append` compileJS' indent cond `T.append`") {\n"
246− `T.append` T.replicate (indent + 2) " " `T.append` compileJS' (indent + 2) e
247− `T.append` ";\n" `T.append` T.replicate indent " " `T.append` "}"
271+ `T.append` T.replicate (indent + 2) " "
272+ `T.append` compileJS' (indent + 2) e
273+ `T.append` ";\n"
274+ `T.append` T.replicate indent " "
275+ `T.append` "}"
248276
249277compileJS' indent (JSSwitch val [(_,JSSeq seq)] Nothing) =
250278 let (h,t) = splitAt 1 seq in
251279 (T.concat (map (compileJS' indent) h) `T.append` ";\n")
252− `T.append` (T.intercalate ";\n" $ map ((T.replicate indent " " `T.append`) . compileJS' indent) t)
280+ `T.append` (
281+ T.intercalate ";\n" $ map (
282+ (T.replicate indent " " `T.append`) . compileJS' indent
283+ ) t
284+ )
253285
254286compileJS' indent (JSSwitch val branches def) =
255287 "switch(" `T.append` compileJS' indent val `T.append` "){\n"
@@ -259,9 +291,13 @@ compileJS' indent (JSSwitch val branches def) =
259291 where
260292 mkBranch :: (JS, JS) -> T.Text
261293 mkBranch (tag, code) =
262− T.replicate (indent + 2) " " `T.append` "case " `T.append` compileJS' indent tag `T.append` ":\n"
294+ T.replicate (indent + 2) " "
295+ `T.append` "case "
296+ `T.append` compileJS' indent tag
297+ `T.append` ":\n"
263298 `T.append` compileJS' (indent + 4) code
264− `T.append` "\n" `T.append` (T.replicate (indent + 4) " " `T.append` "break;\n")
299+ `T.append` "\n"
300+ `T.append` (T.replicate (indent + 4) " " `T.append` "break;\n")
265301
266302 mkDefault :: Maybe JS -> T.Text
267303 mkDefault Nothing = ""
@@ -275,7 +311,13 @@ compileJS' indent (JSTernary cond true false) =
275311 let c = compileJS' indent cond
276312 t = compileJS' indent true
277313 f = compileJS' indent false in
278− "(" `T.append` c `T.append` ")?(" `T.append` t `T.append` "):(" `T.append` f `T.append` ")"
314+ "("
315+ `T.append` c
316+ `T.append` ")?("
317+ `T.append` t
318+ `T.append` "):("
319+ `T.append` f
320+ `T.append` ")"
279321
280322compileJS' indent (JSParens js) =
281323 "(" `T.append` compileJS' indent js `T.append` ")"