Match multiple expressions in case statements#1696
Conversation
|
Seems reasonable to me 👍 We could put the binder length check in |
81b6f8e to
9e75ca9
Compare
|
Example error: case 42, 10, 12 of
42, 10 -> doIt
_ , _ -> return false |
|
I could also do an error for each alternative that is incorrect instead of one for the whole case. Maybe that would be more useful, so you don't have to hunt for them. |
|
That'd be nice - I'm not exactly sure how you'd determine it though... I guess there's a few rules that might work: pick the most common arity first, if there is no common arity then default to the first pattern? |
|
I'd think whatever is in the case head would be treated as the canonical binder length. |
|
Looks nice, thanks! Sorry for the slow response. As for syntax, I think a comma separated list is probably best. The only other thing I can think of is to parenthesize, but that would almost certainly be more confusing for Haskellers since it's valid tuple syntax. |
9e75ca9 to
04033b9
Compare
|
🚢 Thanks! |
|
I've got to fix the test. |
04033b9 to
4dd035e
Compare
|
Ok, should be good to go. I changed it so it emits an error for each alternative with the incorrect number of binders |
|
@garyb Can we get this one merged in for 0.7.7? I'm leaving merges up to you at the moment since I know you had some ordering in mind. If so, @natefaubion, could you please merge master? |
|
Is there going to be a 0.7.7? I figured we were pretty much there with 0.8 now anyway. My order-specific PRs are in now, so merging whatever is fine again, although it looks like something I did means this will need rebasing first. |
|
I wanted to discuss that actually. If there is nothing actually breaking in 0.8, maybe it's fine to skip 0.7.7. |
|
Yeah, so far everything is backwards compatible - or enough so that SlamData still compiles anyway, probably a pretty good test 😄 |
4dd035e to
3a4e356
Compare
|
Rebased. |
|
Thanks! |
|
Somehow this needs rebasing again. I'm not sure why, but I'll be sure to merge it immediately this time. Sorry... |
3a4e356 to
bcb8d32
Compare
|
Done. I think it was a whitespace issue. |
Match multiple expressions in case statements
|
👍 😌 |
This addresses some of the use cases of #1690 and #1687 by allowing you to match multiple expressions at once in a case statement. This is kind of a no-brainer since its already supported by the AST. Thoughts on adding this?
It's currently missing a check for binder/expression length in the branches like we do for arguments in declarations. Where should that be added?