Linear types and pattern synonyms
Linear types cannot be used in pattern synonyms. This ticket is a placeholder to track this as a feature request. If you're interested, please speak up.
As a first step, this requires design. For example, we could support
id :: a %1 -> a
id x = x
nonlinear :: a -> a
nonlinear x = x
f1 (id -> x) = h x
f2 (nonlinear -> x) = h x
f3 (Unrestricted x) = h x
The function f1
is linear iff h
is; the function f2
is never linear; the function f3
is always linear. Perhaps this could be done by annotating the result of a pattern synonym:
pattern P1 :: a %One -> a %One
pattern P2 :: a %Many -> a %Many
pattern P3 :: a %One -> a %Many
but I haven't checked the details. This also requires thinking about the type of matchers in Core.