The cons pattern matches the head and the tail of a nonempty list.
When a cons pattern Ph
:
Pt
is matched against a list type List[
T
]
,
pattern Ph
is matched against type T
,
producing typing context Γh, and
pattern Pt
is matched against type List[
T
]
,
producing typing context Γt.
The typing context produced by the whole match is Γh ∪ Γt.
{- Publish the head and tail of a list as a tuple -} val a = [1, 2, 3] a >x:y> (x, y) {- OUTPUT: (1, [2, 3]) -}