Add Labels
This is an alternative to #1894 to support the implementation of ExtensibleRecords. This version is more complex, but both more orthogonal to the rest of the language, and supports better record features.
- Add a new syntactic class[[BR]]
label -> ( '
(small | large | digit) {small | large | digit | '
}),,<char>,,
A label 'name
is interpreted as a conid at the value level, and as a tycon at the type level, with an implicit declaration:
data 'name = 'name
but with global scope, so the same label in different modules is the same value/type.
- Add a built-in one-parameter type class
Label
with no methods, and for each label'name
an implicit instance
instance Label 'name where
No other instances of Label
are allowed.
- Add a built-in type synonym family
LabelCMP
of kind* -> * -> *
. For every pair of labels'name1
and'name2
, one of the instances
LabelCMP 'name1 'name2 = LabelLT
LabelCMP 'name1 'name2 = LabelEQ
LabelCMP 'name1 'name2 = LabelGT
is implicitly defined, depending on the lexicographic order of 'name1
and 'name2
. No other instances of LabelCMP
are allowed. (The types LabelLT
, LabelEQ
and LabelGT
are datatypes with no constructors, which can be declared in a library.)
Trac metadata
Trac field | Value |
---|---|
Version | 6.8.2 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | Unknown |
Architecture | Unknown |