-
Notifications
You must be signed in to change notification settings - Fork 563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move pattern guards to CoreFn #4496
Comments
Currently, |
Oops! You're right, I missed the outer Edit: Doh! That's not right either. I'll refactor this, but I think the idea still stands 😅 |
I've reverted the change to |
Summary
Move pattern guards to CoreFn, and desugar them as part of codegen.
Motivation
backend-optimizer
optimizes pattern-matching decision trees, but pattern guard desugaring commits too early to a particular control flow through it's CPS translation. If pattern guards were added to CoreFn, we would have more opportunity to analyze these cases and potentially add them to the existing matrix for additional sharing.Proposal
Currently in CoreFn, a
Guard
for a case branch is an alias forExpr
(ie, a single boolean expression).purescript/src/Language/PureScript/CoreFn/Expr.hs
Lines 70 to 73 in 4afea2f
This could be changed to something like:
Alternatively, we could desugar all guards to a
true <- ...
pattern guard and ditch theMaybe
.The text was updated successfully, but these errors were encountered: