Rule 132dm-typbind
Alias Bindings
(132)
Comments
Here , and by the syntactic restrictions the labels are distinct. The constructor takes the fields in the order in which the alias writes them: with type alias P = { y : Int, x : Int }, P 1 2 evaluates to { y = 1, x = 2 }. An alias of the empty record binds its name to the empty record itself (Section 7.4). An alias of any other type binds nothing, and its type constructor is not in ; so rule (126) records in exactly the record aliases.
TeX source
\defnrule[r:dm-typbind]
{\opt{\con=\tycon}}
{\vdash\tycon\ \opt{\kw{=}\ \kw{\kwlb}\lab_1\kw{,}\ \cdots\kw{,}\ \lab_n\kw{\kwrb}}\\
\Rightarrow(\emptyset\opt{\cup\,\{\tycon\}},\ \emptymap\opt{+\,\{\con\mapsto\dmrecord(\lab_1\cdots\lab_n)\}})}Tests (5)
- elm / MinimalTypeAliasTestA type alias of a type name.
- elm / TypeAliasCtorTestChecks that the name of a record type alias can be used as a function that builds the record, taking the fields in the order the alias declares them.
- elm / WideRecordDecoder26TestA 26-field record alias, used as a constructor function, can be filled in one argument at a time by an `andMap` pipeline over `Maybe`.
- elm / WideRecordDecoder30TestA 30-field record alias, used as a constructor function, can be filled in one argument at a time by an `andMap` pipeline over `Maybe`, with fields of different types near the end.
- elm / WideRecordDecoder70TestA 70-field record alias, used as a constructor function, can be filled in one argument at a time by an `andMap` pipeline over `Maybe`.
Discussions
Discuss this rule·Search the discussions on GitHub
Discussions are on GitHub; one about this rule has [r:dm-typbind] in its title.
A Standard Definition of Elm? (Draft version 0.4) © Rupert Smith. The text is licensed under CC BY 4.0: share and adapt it freely, with credit and a link to the licence.