Skip to content
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

Allow where clauses in case labels #364

Open
pschachte opened this issue Nov 15, 2022 · 1 comment
Open

Allow where clauses in case labels #364

pschachte opened this issue Nov 15, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@pschachte
Copy link
Owner

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 ...
}
@pschachte pschachte added the enhancement New feature or request label Nov 15, 2022
@jimbxb
Copy link
Collaborator

jimbxb commented Oct 7, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants