IntersectMBO / IntersectMBO/plutus

Reduce special case handling for CaseReduce on data matching

Open
#7,942 0 comments 0 reactions 1 assignee Claimed by @SeungheonOh View on GitHub
Plinth
Dominant language
Haskell
Stars
1.6k
Forks
508
Avg merge
3d 10h
Merged PRs (30d)
22

Description

#7914 and #7939 now both adds new wrapper for data deconstructor and adds special case handler so that `hoistExpr` can recognize what is for data deconstruction and therefore trigger `CaseReduce` optimization pass. This feels quite ad hoc with several internal wrappers and special casing. Since this also relies on the shape of `match*` handler generated by `asData` as well, it will also fail to optimize when someone passes handler like so:

```hs
let handler x y z = x
in matchFoo ... handler
```

with results in each of the fields getting forced and much more inefficient code.

Ideally, we have a new optimization pass that does not depend on annotation to collapse nested list casing and prune any unused field accessing.

Alternatively, we can also test out having native data declaration supporting data encoding(without asData TH) which will give compiler enough context to determine which field is used and which are not.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.