Elm Exactly

Rule 106d-patrow-field

Pattern RowsE,r⊢patrow⇒VE\jdgv{E}{r}{\patrow}{\VE}
lab∈Dom r⟨E,r⊢patrow⇒VE⟩E,r⊢lab = var ⟨, patrow⟩⇒{var↦r(lab)}⟨+ VE⟩\frac{\begin{array}{c}\lab\in\Dom r\premsep\opt{\jdgv{E}{r}{\patrow}{\VE}}\end{array}}{\begin{array}{c}\jdgv{E}{r}{\lab\ \kw{=}\ \var\ \opt{\kw{,}\ \patrow}}{\{\var\mapsto r(\lab)\}\opt{+\,\VE}}\end{array}}
(106)
Read it in its chapter·Permanent address: /standard/rules/d-patrow-field

Comments

The pattern row binds its variable to the field lab\lab of rr; in a row written as a label alone the variable is spelt as the label (Appendix A). The side condition lab∈Dom r\lab\in\Dom r makes the rule apply exactly when rr has the field; by elaboration it always holds, since a record of the type the pattern requires has every field the pattern row names. Hence a pattern row cannot fail, and its result is a value environment, never FAIL, as rule (104) expects.

TeX source
\defnrule[r:d-patrow-field]
  {\lab\in\Dom r\premsep\opt{\jdgv{E}{r}{\patrow}{\VE}}}
  {\jdgv{E}{r}{\lab\ \kw{=}\ \var\ \opt{\kw{,}\ \patrow}}{\{\var\mapsto r(\lab)\}\opt{+\,\VE}}}

Tests (40)

Discussions

Discuss this rule·Search the discussions on GitHub

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