Skip to content

Match on variant spread in switch #6562

Closed
@jacobp100

Description

@jacobp100

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 {
  | _ => "???"
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions