Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upOptimise (f <<< g $ x) as (f (g x)) #1056
Conversation
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
puffnfresh
Apr 18, 2015
Contributor
Hacked this up pretty quick and it's getting late. Haven't even run tests yet, just putting my work somewhere to track early.
|
Hacked this up pretty quick and it's getting late. Haven't even run tests yet, just putting my work somewhere to track early. |
puffnfresh
reviewed
Apr 18, 2015
| @@ -77,7 +77,8 @@ optimize' js = do | ||
| , inlineOperator (C.prelude, (C.$)) $ \f x -> JSApp f [x] | ||
| , inlineOperator (C.prelude, (C.#)) $ \x f -> JSApp f [x] | ||
| , inlineOperator (C.preludeUnsafe, C.unsafeIndex) $ flip JSIndexer | ||
| , inlineCommonOperators ]) js | ||
| , inlineCommonOperators | ||
| , inlineAppliedArrComposition ]) js |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
puffnfresh
Apr 18, 2015
Contributor
Would this be the right place to put this optimisation? Is there a better order?
puffnfresh
Apr 18, 2015
Contributor
Would this be the right place to put this optimisation? Is there a better order?
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
paf31
Apr 18, 2015
Member
Finding the best order is tricky in general. I've done it by trial and error in the past, but usually I have issues with things like runST and do notation. I don't think there's any issue here though.
paf31
Apr 18, 2015
Member
Finding the best order is tricky in general. I've done it by trial and error in the past, but usually I have issues with things like runST and do notation. I don't think there's any issue here though.
paf31
reviewed
Apr 18, 2015
| @@ -31,6 +32,10 @@ import Language.PureScript.Names | ||
| import Language.PureScript.CodeGen.JS.Optimizer.Common | ||
| import qualified Language.PureScript.Constants as C | ||
| -- TODO: Potential bug: |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
paf31
Apr 18, 2015
Member
Looks great. I was thinking about this today too funnily enough. I should be able to merge this tomorrow.
|
Looks great. I was thinking about this today too funnily enough. I should be able to merge this tomorrow. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
garyb
Apr 18, 2015
Member
Do we inline f $ x at the moment? That case is worth covering too I'd think. Both of these things I'd intended to add in a CoreFn optimizer step, but we don't have one of those yet.
|
Do we inline |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
puffnfresh
Apr 18, 2015
Contributor
@garyb yeah, we do $ already. This optimisation even relies upon that step.
|
@garyb yeah, we do $ already. This optimisation even relies upon that step. |
puffnfresh commentedApr 18, 2015
When writing PureScript code like:
We see a few function calls:
We now see something very straight forward:
The implementation of this optimisation contains a lot of similarities
to the common binary operator inlining. We should extract some
functions out in another commit.