Aconstructor patternhas the form `C p1 p2 … pn'' whereC
is the name of a data constructor in scope, andp1
throughpn
are patterns such thatn
is thearityofC
.Note thatn
may be zero. This pattern matches if the scrutinee reduces to a fully applied invocation of the data constructorC
and the patternsp1
throughpn
match the arguments to the constructor.
For example, this expression usesSome
andNone
,the constructors of theOptional
type, to return the 3rd element of the listxs
if present or0
if there was no 3rd element.