File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
src/Language/PureScript/CodeGen/JS Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,8 @@ optimize' js = do
7878 , inlineOperator (C. prelude, (C. #) ) $ \ x f -> JSApp f [x]
7979 , inlineOperator (C. preludeUnsafe, C. unsafeIndex) $ flip JSIndexer
8080 , inlineCommonOperators
81- , inlineAppliedArrComposition ]) js
81+ , inlineAppliedArrComposition
82+ , inlineAppliedVars ]) js
8283
8384untilFixedPoint :: (Monad m , Eq a ) => (a -> m a ) -> a -> m a
8485untilFixedPoint f = go
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ module Language.PureScript.CodeGen.JS.Optimizer.Inliner (
1919 inlineOperator ,
2020 inlineCommonOperators ,
2121 inlineAppliedArrComposition ,
22+ inlineAppliedVars ,
2223 etaConvert ,
2324 unThunk ,
2425 evaluateIifes
@@ -246,6 +247,13 @@ inlineAppliedArrComposition = everywhereOnJS convert
246247 convert (JSApp (JSApp (JSApp (JSApp fn [dict']) [x]) [y]) [z]) | isDict semigroupoidArr dict' && isPreludeFn (C. <<<) fn = JSApp x [JSApp y [z]]
247248 convert other = other
248249
250+ inlineAppliedVars :: JS -> JS
251+ inlineAppliedVars = everywhereOnJS convert
252+ where
253+ convert :: JS -> JS
254+ convert (JSApp (JSFunction Nothing [a] (JSBlock [JSReturn b])) [JSVar x]) = replaceIdent a (JSVar x) b
255+ convert other = other
256+
249257isDict :: (String , String ) -> JS -> Bool
250258isDict (moduleName, dictName) (JSAccessor x (JSVar y)) = x == dictName && y == moduleName
251259isDict _ _ = False
You can’t perform that action at this time.
0 commit comments