A pattern can matched against a value. If it matches, one or more variables may be bound to some part of the matched value.

Patterns can be used in various declaration contexts, include variable declaration, parameter declarations, and cases of a switch expression.

Abstract pattern grammar

Here is a classifications of patterns why should support. The concrete syntax is not fixed.


The simplest pattern is a variable. This declares that variable, and it is bound to the value being matched against. Question: It may make sense to use a special syntactic marker to indicate a variable being declared, as opposed to being used.

Type specification



This matches pattern1 against the target, possibly binding some variables. Then pattern2 is matches against the same target. The pattern2 may contain use variables bound in pattern1. Commonly, pattern2 will be a predicate or a type-specifier. In fact, perhaps having a special syntax for conjunction may not be useful, since it can be expressed using a predicate.


This matches if the boolean-expression evaluates to true. Typically, boolean-expression may contain variables declared previously in a conjunction. In fact, we could combine the syntaxes:


constructor-name(pattern1, pattern2, ...)