matthew-mojira / cicero

GNU General Public License v3.0
0 stars 0 forks source link

Pattern matching #32

Open matthew-mojira opened 3 weeks ago

matthew-mojira commented 3 weeks ago

A clarification of ideas from #19 and #20:

match val with { -- braces required
  5      -> exactly the value `5`
  x      -> a single-arity value, bound to `x`
  x when x > 0 -> a single-arity value satisfying the when expression
  x: int -> a single-arity value, bound to `x` with type matching type pattern
  (x, y) -> a two-arity value, bound to `x` and `y`
  (5, y) -> a two-arity value, where the first is exactly 5 and the second is bound to `y`
  _      -> wildcard, will match anything and bound nothing
}
matthew-mojira commented 3 weeks ago

Destructuring structured types? (Both user-defined and built-in)