Constructor patterns

Aconstructor patternhas the formC p1 p2 … pnwhereCis the name of a data constructor in scope, andp1throughpnare patterns such thatnis thearityofC.Note thatnmay be zero. This pattern matches if the scrutinee reduces to a fully applied invocation of the data constructorCand the patternsp1throughpnmatch the arguments to the constructor.

For example, this expression usesSomeandNone,the constructors of theOptionaltype, to return the 3rd element of the listxsif present or0if there was no 3rd element.

xs = [0, 2, 3, 4, 5] match List.at 3 xs with None -> 0 Some x -> x
4