Figureappendix-standard-ml-types
| Feature | Standard ML | Elm (this definition) | Where defined here |
| Overloading | A side mechanism (Appendix E of that definition): overloaded identifiers such as + and <, and overloaded special constants, resolved by context, with int as default. | Part of the type system: type variables constrained to the classes , , and , generalised and instantiated like others. A variable that the principal derivation leaves undetermined is taken to be Float before evaluation. | Sec. 4.4; Sec. 4.10; Sec. 6.2 |
| Records | Record types are closed. The selector # and the record pattern wildcard ... require the record type to be determined by the context. No record update. | Record types may be extensible, by a row variable ({ r | x : Int }). Field selection, the field accessor . and record patterns apply to every record with the fields named. Record update { r | x = e } keeps the type of the record. A pattern row stands for , as in SML. | Sec. 4.2; Sec. 4.9; App. A |
| Tuples | A tuple is a record with labels 1, …, (); the unit is the empty record. | Tuples of two and three components have type names of their own, and are not records; the unit is a type of its own. | Fig. 5; Sec. 4.2 |
| Datatypes | datatype with withtype, datatype replication, abstype; datatypes may be declared locally. | Custom types are declared only at the top level of a module. All custom types of a module form one group, and they and the type aliases of the module may mention one another; there is no withtype, replication or abstype. A record alias also declares a constructor. | Fig. 10; Sec. A.2; Sec. 5.5 |
Referred to from
Tests (0)
No test of the suite checks this figure yet.
Discussions
Discuss this figure·Search the discussions on GitHub
Discussions are on GitHub; one about this figure has [fig:appendix-standard-ml-types] 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.