@@ -20,7 +20,7 @@ module Language.PureScript.CodeGen.JS.Optimizer.Inliner (
20 inlineValues,
20 inlineValues,
21 inlineOperator,
21 inlineOperator,
22 inlineCommonOperators,
22 inlineCommonOperators,
23− inlineArrComposition,
23+ inlineFnComposition,
24 etaConvert,
24 etaConvert,
26 evaluateIifes
26 evaluateIifes
@@ -244,18 +244,18 @@ inlineCommonOperators = applyAll $
245-- (f <<< g $ x) = f (g x)
245-- (f <<< g $ x) = f (g x)
246-- (f <<< g) = \x -> f (g x)
246-- (f <<< g) = \x -> f (g x)
247−inlineArrComposition :: (Applicative m, MonadSupply m) => JS -> m JS
247+inlineFnComposition :: (Applicative m, MonadSupply m) => JS -> m JS
248−inlineArrComposition = everywhereOnJSTopDownM convert
248+inlineFnComposition = everywhereOnJSTopDownM convert
250 convert :: (MonadSupply m) => JS -> m JS
250 convert :: (MonadSupply m) => JS -> m JS
251− convert (JSApp (JSApp (JSApp (JSApp fn [dict']) [x]) [y]) [z]) | isArrCompose dict' fn =
251+ convert (JSApp (JSApp (JSApp (JSApp fn [dict']) [x]) [y]) [z]) | isFnCompose dict' fn =
252 return $ JSApp x [JSApp y [z]]
252 return $ JSApp x [JSApp y [z]]
253− convert (JSApp (JSApp (JSApp fn [dict']) [x]) [y]) | isArrCompose dict' fn = do
253+ convert (JSApp (JSApp (JSApp fn [dict']) [x]) [y]) | isFnCompose dict' fn = do
254 arg <- freshName
254 arg <- freshName
255 return $ JSFunction Nothing [arg] (JSBlock [JSReturn $ JSApp x [JSApp y [JSVar arg]]])
255 return $ JSFunction Nothing [arg] (JSBlock [JSReturn $ JSApp x [JSApp y [JSVar arg]]])
256 convert other = return other
256 convert other = return other
257− isArrCompose :: JS -> JS -> Bool
257+ isFnCompose :: JS -> JS -> Bool
258− isArrCompose dict' fn = isDict semigroupoidArr dict' && isPreludeFn (C.<<<) fn
258+ isFnCompose dict' fn = isDict semigroupoidFn dict' && (isPreludeFn (C.<<<) fn || isPreludeFn (C.compose) fn)
260isDict :: (String, String) -> JS -> Bool
260isDict :: (String, String) -> JS -> Bool
261isDict (moduleName, dictName) (JSAccessor x (JSVar y)) = x == dictName && y == moduleName
261isDict (moduleName, dictName) (JSAccessor x (JSVar y)) = x == dictName && y == moduleName
@@ -314,5 +314,5 @@ boundedBoolean = (C.prelude, C.boundedBoolean)
314booleanAlgebraBoolean :: (String, String)
314booleanAlgebraBoolean :: (String, String)
315booleanAlgebraBoolean = (C.prelude, C.booleanAlgebraBoolean)
315booleanAlgebraBoolean = (C.prelude, C.booleanAlgebraBoolean)
317−semigroupoidArr :: (String, String)
317+semigroupoidFn :: (String, String)
318−semigroupoidArr = (C.prelude, C.semigroupoidArr)
318+semigroupoidFn = (C.prelude, C.semigroupoidFn)