plutus icon indicating copy to clipboard operation
plutus copied to clipboard

Optimization: chain of application to `Case` `Constr`

Open SeungheonOh opened this issue 9 months ago • 1 comments

Describe the feature you'd like

(((\a b c -> a + b + c) 10) 20) 30 is more expensive than (case (constr 0 [10, 20, 30]) f) given we apply more than 3 arguments, so we can have transform that converts chained applications into this form.

This is one way of implementing it, but this could be simpler since this deals with some other stuff as well. https://github.com/Plutonomicon/plutarch-plutus/blob/fd7d1c1fc173542f952f19272554027183659dd6/Plutarch/Internal/Term.hs#L705-L723

Describe alternatives you've considered

I read somewhere ApplyN is planned, so once we have that this will be outdated. Though, I think this transformer is simple and good to have enough till than.

SeungheonOh avatar Feb 05 '25 06:02 SeungheonOh