Introduction

You can use a match{} expression to match against a sequence of patterns.

If no match{} clause matches, a run-time error will occur.

Syntax:

<match-expression> :=
    "match" <expression> "{"
    <match-expression-clause> ("," <match-expression-clause>)*
    "}"
    ;

<match-expression-clause> :=
  | <pattern> "=>" <expression>
  | <pattern> "=>" "{" <proposition>+ "}"
  ;

Example

res := match foo() {
  (@ok, val) => val,
  (@error, _reason) => 0
};