Patterns are used in combinators, in
val declarations, and in clausal definitions of functions, to select values and bind variables to values.
A pattern is given by a shape and a set of variables. A shape is either a tuple, a list,
a record, a call, a literal value,
or wildcard (written as
_). If the shape describes a structured value (such as a tuple), its components may
also be shapes. For example, the shape
(_,3) describes all pairs whose second element is
and the pattern
x to the first element of all such pairs.
Note that a pattern may fail to match a value, if it does not have the same shape as that value. When this occurs, the unmatched value is simply discarded.
During typechecking, a pattern is matched against a type instead of a value. This match produces a typing context, which associates a type with each variable that occurs in the pattern.