Aguard patternhas the formp | g
wherep
is a pattern andg
is a Boolean expression that may reference any variables bound inp
.The pattern matches ifp
matches andg
evaluates totrue
.
For example, the following expression evaluates to6
:
match 1 + 2 with
x
| x == 4 -> 0
| x + 1 == 4 -> 6
_ -> 42