pure-c / purec

C backend for PureScript
233 stars 8 forks source link

Port MagicDo optimizer #14

Open felixSchl opened 6 years ago

felixSchl commented 6 years ago

https://github.com/purescript/purescript/blob/b07042fb7b4f6a68c0fdc68b7e51076b7106cfba/src/Language/PureScript/CoreImp/Optimizer/MagicDo.hs

joneshf commented 6 years ago

Do you think it makes sense to push these optimization issues further upstream? Maybe into purescript-corefn if not all the way back up to purescript?

felixSchl commented 6 years ago

The optimizations in the PureScript codebase are performed on the JS AST, not on CoreFn, so I am not quite sure what you mean - would you mind elaborating?

joneshf commented 6 years ago

Some of these transformations could be performed on the CoreFn AST. Like, isn't the majority (if not all) of MagicDo converting calls to bind to let-bindings? Similarly, for things like function composition inlining, that could be done on the CoreFn AST.

There's some that won't work, like inlining (+) or whatever, but some of these could be pushed up to be done once and for all.