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

Match on variant spread in switch #6562

Closed
jacobp100 opened this issue Jan 12, 2024 · 1 comment · Fixed by #6721
Closed

Match on variant spread in switch #6562

jacobp100 opened this issue Jan 12, 2024 · 1 comment · Fixed by #6721

Comments

@jacobp100
Copy link

Since the new ReScript allows spreading variants in the definitions, should we also be able to match them like polymorphic variants?

Polymorphic variants
type ex1A = [#X | #Y]
type ex1B = [#Z]
type ex1 = [ex1A | ex1B]

let ex1 = (x: ex1) =>
  switch x {
  | #...ex1A => "A"
  | #...ex1B => "B"
  }
Variants with spread
type ex2A = X | Y
type ex2B = Z
type ex2 = | ...ex2A | ...ex2B

let ex2 = (x: ex2) =>
  switch x {
  | _ => "???"
  }
@zth
Copy link
Collaborator

zth commented Jan 12, 2024

It'd definitely be great. Related: #6273 (reply in thread)

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

Successfully merging a pull request may close this issue.

2 participants