git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Yet more work on replacing SYB
commitbf47876c413143cce87bad14982f30e1441f723c authorPhil Freeman <paf31@cantab.net> dateMon 14 Apr 2014, 21:15 (13 years ago) parent54116df
10 files changed+133−57
src/Language/PureScript/CodeGen/JS.hs+1−1 src/Language/PureScript/CodeGen/JS/AST.hs+82 src/Language/PureScript/Declarations.hs+10−6 src/Language/PureScript/Optimizer/Blocks.hs+1−3 src/Language/PureScript/Optimizer/Common.hs+12−13 src/Language/PureScript/Optimizer/Inliner.hs+11−13 src/Language/PureScript/Optimizer/MagicDo.hs+6−7 src/Language/PureScript/Optimizer/TCO.hs+6−8 src/Language/PureScript/Optimizer/Unused.hs+3−5 src/Language/PureScript/Sugar/Names.hs+1−1
src/Language/PureScript/CodeGen/JS.hs+1−1
@@ -249,7 +249,7 @@ qualifiedToJS _ f (Qualified _ a) = JSVar $ identToJs (f a)
249249bindersToJs :: Options -> ModuleName -> Environment -> [CaseAlternative] -> [JS] -> JS
250250bindersToJs opts m e binders vals = runGen (map identToJs (unusedNames (binders, vals))) $ do
251251 valNames <- replicateM (length vals) fresh
252− jss <- forM binders $ \(CaseAlternative bs grd result) -> go valNames [JSReturn (valueToJs opts m (bindNames m (binderNames bs) e) result)] bs grd
252+ jss <- forM binders $ \(CaseAlternative bs grd result) -> go valNames [JSReturn (valueToJs opts m (bindNames m (concatMap binderNames bs) e) result)] bs grd
253253 return $ JSApp (JSFunction Nothing valNames (JSBlock (concat jss ++ [JSThrow (JSStringLiteral "Failed pattern match")])))
254254 vals
255255 where
src/Language/PureScript/CodeGen/JS/AST.hs+82
@@ -233,3 +233,85 @@ data JS
233233 -- Raw Javascript (generated when parsing fails for an inline foreign import declaration)
234234 --
235235 | JSRaw String deriving (Show, Eq, Data, Typeable)
236+
237+--
238+-- Traversals
239+--
240+
241+everywhereOnJS :: (JS -> JS) -> JS -> JS
242+everywhereOnJS f = go
243+ where
244+ go :: JS -> JS
245+ go (JSUnary op j) = f (JSUnary op (go j))
246+ go (JSBinary op j1 j2) = f (JSBinary op (go j1) (go j2))
247+ go (JSArrayLiteral js) = f (JSArrayLiteral (map go js))
248+ go (JSIndexer j1 j2) = f (JSIndexer (go j1) (go j2))
249+ go (JSObjectLiteral js) = f (JSObjectLiteral (map (fmap go) js))
250+ go (JSAccessor prop j) = f (JSAccessor prop (go j))
251+ go (JSFunction name args j) = f (JSFunction name args (go j))
252+ go (JSApp j js) = f (JSApp (go j) (map go js))
253+ go (JSConditional j1 j2 j3) = f (JSConditional (go j1) (go j2) (go j3))
254+ go (JSBlock js) = f (JSBlock (map go js))
255+ go (JSVariableIntroduction name j) = f (JSVariableIntroduction name (fmap go j))
256+ go (JSAssignment j1 j2) = f (JSAssignment (go j1) (go j2))
257+ go (JSWhile j1 j2) = f (JSWhile (go j1) (go j2))
258+ go (JSFor name j1 j2 j3) = f (JSFor name (go j1) (go j2) (go j3))
259+ go (JSForIn name j1 j2) = f (JSForIn name (go j1) (go j2))
260+ go (JSIfElse j1 j2 j3) = f (JSIfElse (go j1) (go j2) (fmap go j3))
261+ go (JSReturn js) = f (JSReturn (go js))
262+ go (JSThrow js) = f (JSThrow (go js))
263+ go (JSTypeOf js) = f (JSTypeOf (go js))
264+ go (JSLabel name js) = f (JSLabel name (go js))
265+ go other = f other
266+
267+everywhereOnJSTopDown :: (JS -> JS) -> JS -> JS
268+everywhereOnJSTopDown f = go . f
269+ where
270+ go :: JS -> JS
271+ go (JSUnary op j) = JSUnary op (go (f j))
272+ go (JSBinary op j1 j2) = JSBinary op (go (f j1)) (go (f j2))
273+ go (JSArrayLiteral js) = JSArrayLiteral (map (go . f) js)
274+ go (JSIndexer j1 j2) = JSIndexer (go (f j1)) (go (f j2))
275+ go (JSObjectLiteral js) = JSObjectLiteral (map (fmap (go . f)) js)
276+ go (JSAccessor prop j) = JSAccessor prop (go (f j))
277+ go (JSFunction name args j) = JSFunction name args (go (f j))
278+ go (JSApp j js) = JSApp (go (f j)) (map (go . f) js)
279+ go (JSConditional j1 j2 j3) = JSConditional (go (f j1)) (go (f j2)) (go (f j3))
280+ go (JSBlock js) = JSBlock (map (go . f) js)
281+ go (JSVariableIntroduction name j) = JSVariableIntroduction name (fmap (go . f) j)
282+ go (JSAssignment j1 j2) = JSAssignment (go (f j1)) (go (f j2))
283+ go (JSWhile j1 j2) = JSWhile (go (f j1)) (go (f j2))
284+ go (JSFor name j1 j2 j3) = JSFor name (go (f j1)) (go (f j2)) (go (f j3))
285+ go (JSForIn name j1 j2) = JSForIn name (go (f j1)) (go (f j2))
286+ go (JSIfElse j1 j2 j3) = JSIfElse (go (f j1)) (go (f j2)) (fmap (go . f) j3)
287+ go (JSReturn j) = JSReturn (go (f j))
288+ go (JSThrow j) = JSThrow (go (f j))
289+ go (JSTypeOf j) = JSTypeOf (go (f j))
290+ go (JSLabel name j) = JSLabel name (go (f j))
291+ go other = f other
292+
293+everythingOnJS :: (r -> r -> r) -> (JS -> r) -> JS -> r
294+everythingOnJS (<>) f = go
295+ where
296+ go j@(JSUnary _ j1) = f j <> go j1
297+ go j@(JSBinary _ j1 j2) = f j <> go j1 <> go j2
298+ go j@(JSArrayLiteral js) = foldl (<>) (f j) (map go js)
299+ go j@(JSIndexer j1 j2) = f j <> go j1 <> go j2
300+ go j@(JSObjectLiteral js) = foldl (<>) (f j) (map (go . snd) js)
301+ go j@(JSAccessor _ j1) = f j <> go j1
302+ go j@(JSFunction _ _ j1) = f j <> go j1
303+ go j@(JSApp j1 js) = foldl (<>) (f j <> go j1) (map go js)
304+ go j@(JSConditional j1 j2 j3) = f j <> go j1 <> go j2 <> go j3
305+ go j@(JSBlock js) = foldl (<>) (f j) (map go js)
306+ go j@(JSVariableIntroduction _ (Just j1)) = f j <> go j1
307+ go j@(JSAssignment j1 j2) = f j <> go j1 <> go j2
308+ go j@(JSWhile j1 j2) = f j <> go j1 <> go j2
309+ go j@(JSFor _ j1 j2 j3) = f j <> go j1 <> go j2 <> go j3
310+ go j@(JSForIn _ j1 j2) = f j <> go j1 <> go j2
311+ go j@(JSIfElse j1 j2 Nothing) = f j <> go j1 <> go j2
312+ go j@(JSIfElse j1 j2 (Just j3)) = f j <> go j1 <> go j2 <> go j3
313+ go j@(JSReturn j1) = f j <> go j1
314+ go j@(JSThrow j1) = f j <> go j1
315+ go j@(JSTypeOf j1) = f j <> go j1
316+ go j@(JSLabel _ j1) = f j <> go j1
317+ go other = f other
src/Language/PureScript/Declarations.hs+10−6
@@ -24,7 +24,6 @@ import Language.PureScript.CodeGen.JS.AST
2424import Language.PureScript.Environment
2525
2626import qualified Data.Data as D
27−import Data.Generics (mkQ, everything)
2827
2928-- |
3029-- A precedence level for an infix operator
@@ -441,12 +440,17 @@ data Binder
441440-- |
442441-- Collect all names introduced in binders in an expression
443442--
444−binderNames :: (D.Data d) => d -> [Ident]
445−binderNames = everything (++) (mkQ [] go)
443+binderNames :: Binder -> [Ident]
444+binderNames = go []
446445 where
447− go (VarBinder ident) = [ident]
448− go (NamedBinder ident _) = [ident]
449− go _ = []
446+ go ns (VarBinder name) = name : ns
447+ go ns (ConstructorBinder _ bs) = foldl go ns bs
448+ go ns (ObjectBinder bs) = foldl go ns (map snd bs)
449+ go ns (ArrayBinder bs) = foldl go ns bs
450+ go ns (ConsBinder b1 b2) = go (go ns b1) b2
451+ go ns (NamedBinder name b) = go (name : ns) b
452+ go ns (PositionedBinder _ b) = go ns b
453+ go ns _ = ns
450454
451455--
452456-- Traversals
src/Language/PureScript/Optimizer/Blocks.hs+1−3
@@ -17,15 +17,13 @@ module Language.PureScript.Optimizer.Blocks (
1717 collapseNestedBlocks
1818) where
1919
20−import Data.Generics
21−
2220import Language.PureScript.CodeGen.JS.AST
2321
2422-- |
2523-- Collapse blocks which appear nested directly below another block
2624--
2725collapseNestedBlocks :: JS -> JS
28−collapseNestedBlocks = everywhere (mkT collapse)
26+collapseNestedBlocks = everywhereOnJS collapse
2927 where
3028 collapse :: JS -> JS
3129 collapse (JSBlock sts) = JSBlock (concatMap go sts)
src/Language/PureScript/Optimizer/Common.hs+12−13
@@ -16,27 +16,26 @@
1616module Language.PureScript.Optimizer.Common where
1717
1818import Data.Maybe (fromMaybe)
19−import Data.Generics
2019
2120import Language.PureScript.CodeGen.JS.AST
2221
2322applyAll :: [a -> a] -> a -> a
2423applyAll = foldl1 (.)
2524
26−replaceIdent :: (Data d) => String -> JS -> d -> d
27−replaceIdent var1 js = everywhere (mkT replace)
25+replaceIdent :: String -> JS -> JS -> JS
26+replaceIdent var1 js = everywhereOnJS replace
2827 where
2928 replace (JSVar var2) | var1 == var2 = js
3029 replace other = other
3130
32−replaceIdents :: (Data d) => [(String, JS)] -> d -> d
33−replaceIdents vars = everywhere (mkT replace)
31+replaceIdents :: [(String, JS)] -> JS -> JS
32+replaceIdents vars = everywhereOnJS replace
3433 where
3534 replace v@(JSVar var) = fromMaybe v $ lookup var vars
3635 replace other = other
3736
38−isReassigned :: (Data d) => String -> d -> Bool
39−isReassigned var1 = everything (||) (mkQ False check)
37+isReassigned :: String -> JS -> Bool
38+isReassigned var1 = everythingOnJS (||) check
4039 where
4140 check :: JS -> Bool
4241 check (JSFunction _ args _) | var1 `elem` args = True
@@ -46,14 +45,14 @@ isReassigned var1 = everything (||) (mkQ False check)
4645 check (JSForIn arg _ _) | var1 == arg = True
4746 check _ = False
4847
49−isRebound :: (Data d) => JS -> d -> Bool
50−isRebound js d = any (\v -> isReassigned v d || isUpdated v d) (everything (++) (mkQ [] variablesOf) js)
48+isRebound :: JS -> JS -> Bool
49+isRebound js d = any (\v -> isReassigned v d || isUpdated v d) (everythingOnJS (++) variablesOf js)
5150 where
5251 variablesOf (JSVar var) = [var]
5352 variablesOf _ = []
5453
55−isUsed :: (Data d) => String -> d -> Bool
56−isUsed var1 = everything (||) (mkQ False check)
54+isUsed :: String -> JS -> Bool
55+isUsed var1 = everythingOnJS (||) check
5756 where
5857 check :: JS -> Bool
5958 check (JSVar var2) | var1 == var2 = True
@@ -66,8 +65,8 @@ targetVariable (JSAccessor _ tgt) = targetVariable tgt
6665targetVariable (JSIndexer _ tgt) = targetVariable tgt
6766targetVariable _ = error "Invalid argument to targetVariable"
6867
69−isUpdated :: (Data d) => String -> d -> Bool
70−isUpdated var1 = everything (||) (mkQ False check)
68+isUpdated :: String -> JS -> Bool
69+isUpdated var1 = everythingOnJS (||) check
7170 where
7271 check :: JS -> Bool
7372 check (JSAssignment target _) | var1 == targetVariable target = True
src/Language/PureScript/Optimizer/Inliner.hs+11−13
@@ -22,8 +22,6 @@ module Language.PureScript.Optimizer.Inliner (
2222 evaluateIifes
2323) where
2424
25−import Data.Generics
26−
2725import Language.PureScript.CodeGen.JS.AST
2826import Language.PureScript.CodeGen.Common (identToJs)
2927import Language.PureScript.Optimizer.Common
@@ -41,42 +39,42 @@ shouldInline (JSIndexer index val) = shouldInline index && shouldInline val
4139shouldInline _ = False
4240
4341etaConvert :: JS -> JS
44−etaConvert = everywhere (mkT convert)
42+etaConvert = everywhereOnJS convert
4543 where
4644 convert :: JS -> JS
4745 convert (JSBlock [JSReturn (JSApp (JSFunction Nothing idents block@(JSBlock body)) args)])
4846 | all shouldInline args &&
4947 not (any (`isRebound` block) (map JSVar idents)) &&
5048 not (any (`isRebound` block) args)
51− = JSBlock (replaceIdents (zip idents args) body)
49+ = JSBlock (map (replaceIdents (zip idents args)) body)
5250 convert js = js
5351
5452unThunk :: JS -> JS
55−unThunk = everywhere (mkT convert)
53+unThunk = everywhereOnJS convert
5654 where
5755 convert :: JS -> JS
5856 convert (JSBlock [JSReturn (JSApp (JSFunction Nothing [] (JSBlock body)) [])]) = JSBlock body
5957 convert js = js
6058
6159evaluateIifes :: JS -> JS
62−evaluateIifes = everywhere (mkT convert)
60+evaluateIifes = everywhereOnJS convert
6361 where
6462 convert :: JS -> JS
6563 convert (JSApp (JSFunction Nothing [] (JSBlock [JSReturn ret])) []) = ret
6664 convert js = js
6765
6866inlineVariables :: JS -> JS
69−inlineVariables = everywhere (mkT $ removeFromBlock go)
67+inlineVariables = everywhereOnJS $ removeFromBlock go
7068 where
7169 go :: [JS] -> [JS]
7270 go [] = []
7371 go (JSVariableIntroduction var (Just js) : sts)
74− | shouldInline js && not (isReassigned var sts) && not (isRebound js sts) && not (isUpdated var sts) =
75− go (replaceIdent var js sts)
72+ | shouldInline js && not (any (isReassigned var) sts) && not (any (isRebound js) sts) && not (any (isUpdated var) sts) =
73+ go (map (replaceIdent var js) sts)
7674 go (s:sts) = s : go sts
7775
7876inlineOperator :: (String, String) -> (JS -> JS -> JS) -> JS -> JS
79−inlineOperator (m, op) f = everywhere (mkT convert)
77+inlineOperator (m, op) f = everywhereOnJS convert
8078 where
8179 convert :: JS -> JS
8280 convert (JSApp (JSApp op' [x]) [y]) | isOp op' = f x y
@@ -122,7 +120,7 @@ inlineCommonOperators = applyAll
122120 ]
123121 where
124122 binary :: String -> String -> BinaryOperator -> JS -> JS
125− binary dictName opString op = everywhere (mkT convert)
123+ binary dictName opString op = everywhereOnJS convert
126124 where
127125 convert :: JS -> JS
128126 convert (JSApp (JSApp (JSApp fn [dict]) [x]) [y]) | isOp fn && isOpDict dictName dict = JSBinary op x y
@@ -131,7 +129,7 @@ inlineCommonOperators = applyAll
131129 isOp (JSIndexer (JSStringLiteral op') (JSVar prelude)) = prelude == C.prelude && opString == op'
132130 isOp _ = False
133131 binaryFunction :: String -> String -> BinaryOperator -> JS -> JS
134− binaryFunction dictName fnName op = everywhere (mkT convert)
132+ binaryFunction dictName fnName op = everywhereOnJS convert
135133 where
136134 convert :: JS -> JS
137135 convert (JSApp (JSApp (JSApp fn [dict]) [x]) [y]) | isOp fn && isOpDict dictName dict = JSBinary op x y
@@ -139,7 +137,7 @@ inlineCommonOperators = applyAll
139137 isOp (JSAccessor fnName' (JSVar prelude)) = prelude == C.prelude && fnName == fnName'
140138 isOp _ = False
141139 unary :: String -> String -> UnaryOperator -> JS -> JS
142− unary dictName fnName op = everywhere (mkT convert)
140+ unary dictName fnName op = everywhereOnJS convert
143141 where
144142 convert :: JS -> JS
145143 convert (JSApp (JSApp fn [dict]) [x]) | isOp fn && isOpDict dictName dict = JSUnary op x
src/Language/PureScript/Optimizer/MagicDo.hs+6−7
@@ -20,7 +20,6 @@ module Language.PureScript.Optimizer.MagicDo (
2020
2121import Data.List (nub)
2222import Data.Maybe (fromJust, isJust)
23−import Data.Generics
2423
2524import Language.PureScript.Options
2625import Language.PureScript.CodeGen.JS.AST
@@ -50,7 +49,7 @@ magicDo opts | optionsNoMagicDo opts = id
5049-- }
5150--
5251magicDo' :: JS -> JS
53−magicDo' = everywhere (mkT undo) . everywhere' (mkT convert)
52+magicDo' = everywhereOnJS undo . everywhereOnJSTopDown convert
5453 where
5554 -- The name of the function block which is added to denote a do block
5655 fnName = "__do"
@@ -106,7 +105,7 @@ magicDo' = everywhere (mkT undo) . everywhere' (mkT convert)
106105-- Inline functions in the ST module
107106--
108107inlineST :: JS -> JS
109−inlineST = everywhere (mkT convertBlock)
108+inlineST = everywhereOnJS convertBlock
110109 where
111110 -- Look for runST blocks and inline the STRefs there.
112111 -- If all STRefs are used in the scope of the same runST, only using { read, write, modify }STRef then
@@ -116,7 +115,7 @@ inlineST = everywhere (mkT convertBlock)
116115 usages = findAllSTUsagesIn arg
117116 allUsagesAreLocalVars = all (\u -> let v = toVar u in isJust v && fromJust v `elem` refs) usages
118117 localVarsDoNotEscape = all (\r -> length (r `appearingIn` arg) == length (filter (\u -> let v = toVar u in v == Just r) usages)) refs
119− in everywhere (mkT $ convert (allUsagesAreLocalVars && localVarsDoNotEscape)) arg
118+ in everywhereOnJS (convert (allUsagesAreLocalVars && localVarsDoNotEscape)) arg
120119 convertBlock other = other
121120 -- Convert a block in a safe way, preserving object wrappers of references,
122121 -- or in a more aggressive way, turning wrappers into local variables depending on the
@@ -138,18 +137,18 @@ inlineST = everywhere (mkT convertBlock)
138137 isSTFunc name (JSAccessor name' (JSVar st)) = st == C.st && name == name'
139138 isSTFunc _ _ = False
140139 -- Find all ST Refs initialized in this block
141− findSTRefsIn = everything (++) (mkQ [] isSTRef)
140+ findSTRefsIn = everythingOnJS (++) isSTRef
142141 where
143142 isSTRef (JSVariableIntroduction ident (Just (JSApp (JSApp f [_]) []))) | isSTFunc C.newSTRef f = [ident]
144143 isSTRef _ = []
145144 -- Find all STRefs used as arguments to readSTRef, writeSTRef, modifySTRef
146− findAllSTUsagesIn = everything (++) (mkQ [] isSTUsage)
145+ findAllSTUsagesIn = everythingOnJS (++) isSTUsage
147146 where
148147 isSTUsage (JSApp (JSApp f [ref]) []) | isSTFunc C.readSTRef f = [ref]
149148 isSTUsage (JSApp (JSApp (JSApp f [ref]) [_]) []) | isSTFunc C.writeSTRef f || isSTFunc C.modifySTRef f = [ref]
150149 isSTUsage _ = []
151150 -- Find all uses of a variable
152− appearingIn ref = everything (++) (mkQ [] isVar)
151+ appearingIn ref = everythingOnJS (++) isVar
153152 where
154153 isVar e@(JSVar v) | v == ref = [e]
155154 isVar _ = []
src/Language/PureScript/Optimizer/TCO.hs+6−8
@@ -15,8 +15,6 @@
1515
1616module Language.PureScript.Optimizer.TCO (tco) where
1717
18−import Data.Generics
19−
2018import Language.PureScript.Options
2119import Language.PureScript.CodeGen.JS.AST
2220
@@ -28,7 +26,7 @@ tco opts | optionsNoTco opts = id
2826 | otherwise = tco'
2927
3028tco' :: JS -> JS
31−tco' = everywhere (mkT convert)
29+tco' = everywhereOnJS convert
3230 where
3331 tcoLabel :: String
3432 tcoLabel = "tco"
@@ -61,9 +59,9 @@ tco' = everywhere (mkT convert)
6159 isTailCall :: String -> JS -> Bool
6260 isTailCall ident js =
6361 let
64− numSelfCalls = everything (+) (mkQ 0 countSelfCalls) js
65− numSelfCallsInTailPosition = everything (+) (mkQ 0 countSelfCallsInTailPosition) js
66− numSelfCallsUnderFunctions = everything (+) (mkQ 0 countSelfCallsUnderFunctions) js
62+ numSelfCalls = everythingOnJS (+) countSelfCalls js
63+ numSelfCallsInTailPosition = everythingOnJS (+) countSelfCallsInTailPosition js
64+ numSelfCallsUnderFunctions = everythingOnJS (+) countSelfCallsUnderFunctions js
6765 in
6866 numSelfCalls > 0
6967 && numSelfCalls == numSelfCallsInTailPosition
@@ -75,12 +73,12 @@ tco' = everywhere (mkT convert)
7573 countSelfCallsInTailPosition :: JS -> Int
7674 countSelfCallsInTailPosition (JSReturn ret) | isSelfCall ident ret = 1
7775 countSelfCallsInTailPosition _ = 0
78− countSelfCallsUnderFunctions (JSFunction _ _ js') = everything (+) (mkQ 0 countSelfCalls) js'
76+ countSelfCallsUnderFunctions (JSFunction _ _ js') = everythingOnJS (+) countSelfCalls js'
7977 countSelfCallsUnderFunctions _ = 0
8078 toLoop :: String -> [String] -> JS -> JS
8179 toLoop ident allArgs js = JSBlock $
8280 map (\arg -> JSVariableIntroduction arg (Just (JSVar (copyVar arg)))) allArgs ++
83− [ JSLabel tcoLabel $ JSWhile (JSBooleanLiteral True) (JSBlock [ everywhere (mkT loopify) js ]) ]
81+ [ JSLabel tcoLabel $ JSWhile (JSBooleanLiteral True) (JSBlock [ everywhereOnJS loopify js ]) ]
8482 where
8583 loopify :: JS -> JS
8684 loopify (JSReturn ret) | isSelfCall ident ret =
src/Language/PureScript/Optimizer/Unused.hs+3−5
@@ -18,23 +18,21 @@ module Language.PureScript.Optimizer.Unused (
1818 removeCodeAfterReturnStatements
1919) where
2020
21−import Data.Generics
22−
2321import Language.PureScript.CodeGen.JS.AST
2422import Language.PureScript.Optimizer.Common
2523
2624removeUnusedVariables :: JS -> JS
27−removeUnusedVariables = everywhere (mkT $ removeFromBlock withBlock)
25+removeUnusedVariables = everywhereOnJS (removeFromBlock withBlock)
2826 where
2927 withBlock :: [JS] -> [JS]
3028 withBlock sts = go sts sts
3129 go :: [JS] -> [JS] -> [JS]
3230 go _ [] = []
33− go sts (JSVariableIntroduction var _ : rest) | not (isUsed var sts) = go sts rest
31+ go sts (JSVariableIntroduction var _ : rest) | not (any (isUsed var) sts) = go sts rest
3432 go sts (s : rest) = s : go sts rest
3533
3634removeCodeAfterReturnStatements :: JS -> JS
37−removeCodeAfterReturnStatements = everywhere (mkT $ removeFromBlock go)
35+removeCodeAfterReturnStatements = everywhereOnJS (removeFromBlock go)
3836 where
3937 go :: [JS] -> [JS]
4038 go jss | not (any isJSReturn jss) = jss
src/Language/PureScript/Sugar/Names.hs+1−1
@@ -215,7 +215,7 @@ renameInModule imports exports (Module mn decls exps) =
215215 bindFunctionArgs pb other = return (pb, other)
216216
217217 bindBinders :: (Maybe SourcePos, [Ident]) -> CaseAlternative -> Either ErrorStack ((Maybe SourcePos, [Ident]), CaseAlternative)
218− bindBinders (pos, bound) c@(CaseAlternative bs _ _) = return ((pos, binderNames bs ++ bound), c)
218+ bindBinders (pos, bound) c@(CaseAlternative bs _ _) = return ((pos, concatMap binderNames bs ++ bound), c)
219219
220220 letBoundVariable :: Declaration -> Maybe Ident
221221 letBoundVariable (ValueDeclaration ident _ _ _ _) = Just ident