| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
UntypedPlutusCore.Transform.LetFloatOut
Description
Floats immediately-applied lambdas ("let bindings") outwards, as long as doing so cannot cause any expression to be evaluated more than before.
This can unlock further optimizations, such as case-constr and force-delay cancellation.
Specifically, it floats bindings from the following positions: case scrutinee,
force body, and the function of apply.
If we don't care about the order of effects, we can also float bindings from apply
arguments and constr arguments, but there's no evidence that doing so is beneficial,
so we don't do it.
This pass only floats one bindings from each location. Since the pass runs once per
simplifier iteration, this should be sufficient. Floating out multi-lets at once would
complicate things, since we'd need to consider both (a b. M) A B and
(a. (b -> M) B) A.
Documentation
letFloatOut ∷ (MonadQuote m, Rename (Term name uni fun a)) ⇒ Term name uni fun a → OptimizerT name uni fun a m (Term name uni fun a) Source #