summaryrefslogtreecommitdiff
path: root/src/Language/PureScript/CoreImp/Optimizer/Blocks.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Language/PureScript/CoreImp/Optimizer/Blocks.hs')
-rw-r--r--src/Language/PureScript/CoreImp/Optimizer/Blocks.hs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/Language/PureScript/CoreImp/Optimizer/Blocks.hs b/src/Language/PureScript/CoreImp/Optimizer/Blocks.hs
index 47b2373..04febf2 100644
--- a/src/Language/PureScript/CoreImp/Optimizer/Blocks.hs
+++ b/src/Language/PureScript/CoreImp/Optimizer/Blocks.hs
@@ -10,19 +10,19 @@ import Language.PureScript.CoreImp.AST
-- | Collapse blocks which appear nested directly below another block
collapseNestedBlocks :: AST -> AST
-collapseNestedBlocks = everywhere collapse
- where
+collapseNestedBlocks = everywhere collapse where
collapse :: AST -> AST
collapse (Block ss sts) = Block ss (concatMap go sts)
collapse js = js
+
go :: AST -> [AST]
go (Block _ sts) = sts
go s = [s]
collapseNestedIfs :: AST -> AST
-collapseNestedIfs = everywhere collapse
- where
+collapseNestedIfs = everywhere collapse where
collapse :: AST -> AST
+ collapse (IfElse _ (BooleanLiteral _ True) (Block _ [js]) _) = js
collapse (IfElse s1 cond1 (Block _ [IfElse s2 cond2 body Nothing]) Nothing) =
IfElse s1 (Binary s2 And cond1 cond2) body Nothing
collapse js = js