wybe
wybe copied to clipboard
Allow `where` clauses in case labels
This would be like having guards in case labels in Haskell. Syntax would be something like:
case foo in {
[] :: ... handle empty list ...
[?singleton] where prime(singleton) :: ... handle prime singleton ...
[?head|?tail] :: ... handle other non-empty list cases ...
}
I like this idea.
Implementation, after parsing this structure should be fairly straightforward. As case
statements are flattened into nested if
statements, the pattern's test can be prepended to the where
's conditions, forming the test for that case.