Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
UntypedPlutusCore.Transform.CaseOfCase
Description
Perform the case-of-case transformation. This pushes case expressions into the case branches of other case expressions, which can often yield optimization opportunities.
Example: @ case (case s of { C1 a -> x; C2 b -> y; }) of D1 -> w D2 -> z
- ->
case s of C1 a -> case x of { D1 -> w; D2 -> z; } C2 b -> case y of { D1 -> w; D2 -> z; } @
We also transform
case ((force ifThenElse) b (constr t) (constr f)) alts
into
force (force ifThenElse b (delay (case (constr t) alts)) (delay (case (constr f) alts)))
This is always an improvement.
Documentation
caseOfCase ∷ (fun ~ DefaultFun, Monad m, CaseBuiltin uni, GEq uni, Closed uni, uni `Everywhere` Eq) ⇒ Term name uni fun a → SimplifierT name uni fun a m (Term name uni fun a) Source #