The following is a partial specification; nothing more is guaranteed. Informally, when patterns overlap, more specific patterns are preferred to more specific ones. Apart from that, the choice is unspecified. More formally:
Matching a value with a pattern involves evaluating the value sufficiently to compare its data constants and constructors with those in the pattern, in some consistent, top-to-bottom (but otherwise unspecified) order. This match may result in
A pattern (or sub-pattern) consisting only of variables and pairs always matches a value of the appropriate type, even if computation of the value would not terminate. Such patterns are called irrefutable.
Now suppose a function has been defined by a series of definitions
--f
p
_i1
...
p
_in
<=e
_i
;for i = 1, ..., k, or is the expression
lambdap
_11
...
p
_1n
=>e
_1
|...
|p
_k1
...
p
_kn
=>e
_k
(At present, anonymous functions are required to be unary.) An application of this function to n argument values will have zero or more possible values, as follows: