Elm Exactly

Rule 9s-atexp-update

Atomic ExpressionsC⊢atexp⇒τ\jdg{C}{\atexp}{\tau}
C⊢var⇒ττ∈RecTypeC⊢exprow⇒ϱϱ⊆(ϱofτ)C⊢{ var | exprow }⇒τ\frac{\begin{array}{c}\jdg{C}{\var}{\tau} \premsep \tau \in \RecType \premsep \jdg{C}{\exprow}{\varrho} \premsep \varrho \subseteq (\varrho \of \tau)\end{array}}{\begin{array}{c}\jdg{C}{\kw{\kwlb}\ \var\ \kw{|}\ \exprow\ \kw{\kwrb}}{\tau}\end{array}}
(9)
Read it in its chapter·Permanent address: /standard/rules/s-atexp-update

Comments

The side conditions require the type of var\var to be a record type that has every updated field, each at the type of its new value. The result has the type of var\var, so an update neither adds a field nor changes the type of one: if r\kw{r} has type {{x↦Int}}\rec{\{\kw{x} \mapsto \tInt\}} then { r | x = "s" } does not elaborate. The type of var\var may be open, so a function may update a field of any record that has it.

TeX source
\defnrule[r:s-atexp-update]
  {\jdg{C}{\var}{\tau} \premsep \tau \in \RecType \premsep \jdg{C}{\exprow}{\varrho} \premsep \varrho \subseteq (\varrho \of \tau)}
  {\jdg{C}{\kw{\kwlb}\ \var\ \kw{|}\ \exprow\ \kw{\kwrb}}{\tau}}

Tests (16)

Discussions

Discuss this rule·Search the discussions on GitHub

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