Opened 12 years ago

Closed 5 years ago

#2104 closed feature request (fixed)

Add Labels

Reported by: barney Owned by:
Priority: lowest Milestone: 7.10.1
Component: Compiler Version: 6.8.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

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.

  1. Add a new syntactic class

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.

  1. 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.

  1. 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.)

Change History (15)

comment:1 Changed 12 years ago by igloo

difficulty: Unknown

Thanks for the suggestion; I'll put it in the 6.10 milestone for now.

comment:2 Changed 12 years ago by barney

We probably want labels to be automatically in most of the standard classes, with trivial instances like

instance Eq 'name where
    _==_ = True

so that deriving works for types constructed from them.

comment:3 Changed 11 years ago by igloo

Milestone: 6.10 branch

comment:4 Changed 11 years ago by simonmar

Architecture: UnknownUnknown/Multiple

comment:5 Changed 11 years ago by simonmar

Operating System: UnknownUnknown/Multiple

comment:6 Changed 10 years ago by igloo

Milestone: 6.10 branch6.12 branch

comment:7 Changed 9 years ago by igloo

Milestone: 6.12 branch6.12.3

comment:8 Changed 9 years ago by igloo

Milestone: 6.12.36.14.1
Priority: normallow

comment:9 Changed 9 years ago by igloo

Milestone: 7.0.17.0.2

comment:10 Changed 9 years ago by igloo

Milestone: 7.0.27.2.1

comment:11 Changed 8 years ago by igloo

Milestone: 7.2.17.4.1

comment:12 Changed 8 years ago by igloo

Milestone: 7.4.17.6.1
Priority: lowlowest

comment:13 Changed 7 years ago by igloo

Milestone: 7.6.17.6.2

comment:14 Changed 5 years ago by thoughtpolice

Milestone: 7.6.27.10.1

Moving to 7.10.1.

comment:15 Changed 5 years ago by barney

Resolution: fixed
Status: newclosed
Type of failure: None/Unknown

I set this as fixed, because it's completely subsumed by Symbol.

Note: See TracTickets for help on using tickets.