Currently, match type reduction is not specified, and its implementation is by nature not specifiable.
This is an issue because match type reduction spans across TASTy files (unlike, for example, type inference or GADTs), which can and will lead to old TASTy files not to be linked again in future versions of the compiler.
We propose a proper specification for match types, which does not involve type inference.
It is based on baseType
computations and subtype tests involving only fully-defined types.
That is future-proof, because baseType
and subtyping are defined in the specification of the language.
The proposed specification defines a subset of current match types that are considered legal.
Legal match types use the new, specified reduction rules.
Illegal match types are rejected, which is a breaking change, and can be recovered under -source:3.3
.
In exchange, the proposal promises that patterns that are legal will actually keep working in a backward compatible way in the future (which is not the case with the current implementation, even for the legal subset).
See the full proposal already in the SIP repo. Its specification-heavy nature made it impractical to write the proposal in this forum without more infrastructure:
Comments welcome.