plutus-core-1.68.0.0: Language library for Plutus Core
Safe HaskellSafe-Inferred
LanguageHaskell2010

UntypedPlutusCore.Transform.ApplyToCase

Description

Transform multi-argument applications into case-constr form.

This is essentially the reverse of CaseReduce. An application of 3 or more arguments, e.g., f x y z is rewritten to case (constr 0 [x, y, z]) [f], which is cheaper, and smaller in AST size, though it is sometimes slightly bigger in cbor size.

I cannot think of any case where this pass could enable further optimizations. It can certainly destroy optimization opportunities, similar to CSE. So it should only be run once, at the very end of the pipeline. CSE is also run at the end, but it runs for multiple iterations interleaved with other optimizations, because CSE can both destroy and enable further optimizations.

Documentation

applyToCaseMonad m ⇒ Term name uni fun a → OptimizerT name uni fun a m (Term name uni fun a) Source #