aristanetworks / purescript-backend-optimizer

Optimizing backend toolkit and modern ECMAScript backend for PureScript
MIT License
201 stars 18 forks source link

Generate empty CtorSaturated, optimize it in codegen instead #98

Closed MonoidMusician closed 1 year ago

MonoidMusician commented 1 year ago

This is useful for other backends where constructing data is cheap and cross-module references are expensive (like Erlang, where top-level declarations need to be functions). It would be difficult to reconstruct what Var reference is really a nullary ctor during codegen, so it is better to keep the constructors and let backend-es optimize the nullary case to its liking.

There's tiny differences in optimizations in the snapshots:

natefaubion commented 1 year ago

I think the codegen changes happen because these functions now analyze as evaluating to a KnownNeutral, where the previous Var encoding made it opaque. I think that's desirable.

natefaubion commented 1 year ago

cc @anttih This will affect the scheme backend likely.