on master help sign in
Improve indentation style
commit68fdeffdea7f6a42d3ab4f09ad441b16504326af authorEvan Czaplicki <info@elm-lang.org> dateTue 17 Feb 2015, 20:38 (12 years ago) parentda476ff
1 file changed+26−21
src/Generate/JavaScript.hs+26−21
src/Generate/JavaScript.hs+26−21
@@ -33,10 +33,10 @@ internalImports name =
3333 , include "_P" "Ports"
3434 , varDecl Help.localModuleName (string (Module.nameToString name))
3535 ]
36− where
37− include :: String -> String -> VarDecl ()
38− include alias modul =
39− varDecl alias (Help.make ["_N", modul])
36+ where
37+ include :: String -> String -> VarDecl ()
38+ include alias modul =
39+ varDecl alias (Help.make ["_N", modul])
4040
4141
4242_Utils :: String -> Expression ()
@@ -256,13 +256,14 @@ match :: Region -> Case.Match -> State Int [Statement ()]
256256match region mtch =
257257 case mtch of
258258 Case.Match name clauses mtch' ->
259− do (isChars, clauses') <- unzip <$> mapM (clause region name) clauses
260− mtch'' <- match region mtch'
261− return (SwitchStmt () (format isChars (access name)) clauses' : mtch'')
259+ do (isChars, clauses') <- unzip <$> mapM (clause region name) clauses
260+ mtch'' <- match region mtch'
261+ return (SwitchStmt () (format isChars (access name)) clauses' : mtch'')
262262 where
263− isLiteral p = case p of
264− Case.Clause (Right _) _ _ -> True
265− _ -> False
263+ isLiteral p =
264+ case p of
265+ Case.Clause (Right _) _ _ -> True
266+ _ -> False
266267
267268 access name
268269 | any isLiteral clauses = obj [name]
@@ -275,26 +276,30 @@ match region mtch =
275276 Case.Fail ->
276277 return [ ExprStmt () (Help.throw "badCase" region) ]
277278
278− Case.Break -> return [BreakStmt () Nothing]
279+ Case.Break ->
280+ return [BreakStmt () Nothing]
279281
280282 Case.Other e ->
281− do e' <- expression e
282− return [ ret e' ]
283+ do e' <- expression e
284+ return [ ret e' ]
283285
284− Case.Seq ms -> concat <$> mapM (match region) (dropEnd [] ms)
285− where
286− dropEnd acc [] = acc
287− dropEnd acc (m:ms) =
288− case m of
289− Case.Other _ -> acc ++ [m]
290− _ -> dropEnd (acc ++ [m]) ms
286+ Case.Seq ms ->
287+ concat <$> mapM (match region) (dropEnd [] ms)
288+ where
289+ dropEnd acc [] = acc
290+ dropEnd acc (m:ms) =
291+ case m of
292+ Case.Other _ -> acc ++ [m]
293+ _ -> dropEnd (acc ++ [m]) ms
291294
292295
293296clause :: Region -> String -> Case.Clause -> State Int (Bool, CaseClause ())
294297clause region variable (Case.Clause value vars mtch) =
295298 (,) isChar . CaseClause () pattern <$> match region (Case.matchSubst (zip vars vars') mtch)
296299 where
297− vars' = map (\n -> variable ++ "._" ++ show n) [0..]
300+ vars' =
301+ map (\n -> variable ++ "._" ++ show n) [0..]
302+
298303 (isChar, pattern) =
299304 case value of
300305 Right (Chr c) -> (True, string [c])