Elm Exactly

Rule 131dm-conbind

Constructor Bindings⊢conbind⇒VE\jdg{}{\conbind}{\VE}
⟨⊢conbind⇒VE⟩⊢con ⟨| conbind⟩⇒{con↦con}⟨+ VE⟩\frac{\begin{array}{c}\opt{\jdg{}{\conbind}{\VE}}\end{array}}{\begin{array}{c}\jdg{}{\con\ \opt{\kw{|}\ \conbind}}{\{\con\mapsto\con\}\opt{+\,\VE}}\end{array}}
(131)
Read it in its chapter·Permanent address: /standard/rules/dm-conbind

Comments

The constructor value con\con awaits all arity(con)\arity(\con) of its arguments; a constructor of arity 0 is thus a complete value. Constructors spelt alike in different modules give equal constructor values, which never meet in one rule, since they have different types (Section 6.3).

TeX source
\defnrule[r:dm-conbind]
  {\opt{\jdg{}{\conbind}{\VE}}}
  {\jdg{}{\con\ \opt{\kw{|}\ \conbind}}{\{\con\mapsto\con\}\opt{+\,\VE}}}

Tests (4)

  • elm / MinimalCustomTypeTest
    A custom type with one constructor.
  • elm / UserBoolNamedCtorTest
    A custom type may name its own constructors `True` and `False`, and they behave as ordinary constructors, distinct from each other and from `Unknown`.
  • elm / WideCtorField24Test
    A custom type constructor with 27 fields, 25 `Int`s followed by a `Float` and a `Char`, keeps every field, and pattern matching reads back the later ones.
  • elm / WideCtorMixedTest
    A custom type constructor with 60 fields, cycling through `Int`, `Float`, `Char`, `String` and `Bool`, supports pattern matching, equality and printing.

Discussions

Discuss this rule·Search the discussions on GitHub

Discussions are on GitHub; one about this rule has [r:dm-conbind] 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.