Elm Exactly

Rule 153e-enc-record

EncodingEncτ(v)=j\Enc{\tau}(v)=j
Dom r=Dom ϱj∈Str→finBValDom j=Dom ϱEncϱ(lab)(r(lab))=j(lab) for each lab∈Dom ϱEnc{ϱ}(r)=j\frac{\begin{array}{c}\Dom r=\Dom\varrho\premsep j\in\effStr\finmap\BVal\premsep\Dom j=\Dom\varrho\\ \Enc{\varrho(\lab)}(r(\lab))=j(\lab)\ \text{for each}\ \lab\in\Dom\varrho\end{array}}{\begin{array}{c}\Enc{\rec{\varrho}}(r)=j\end{array}}
(153)
Read it in its chapter·Permanent address: /standard/rules/e-enc-record

Comments

The fields become the keys of an object, which has no order, so the order of fields is no part of what is sent.

TeX source
\defnrule[r:e-enc-record]
  {\Dom r=\Dom\varrho\premsep j\in\effStr\finmap\BVal\premsep\Dom j=\Dom\varrho\\
   \Enc{\varrho(\lab)}(r(\lab))=j(\lab)\ \text{for each}\ \lab\in\Dom\varrho}
  {\Enc{\rec{\varrho}}(r)=j}

Tests (3)

  • elm / MinimalPipeRecordTest
    A pipe at `{ a : Int }`: the value the driver sends in comes back out.
  • elm / PortAliasEchoTest
    An outgoing port whose type is written through a type alias, `port echoOut : Out msg` with `type alias Out msg = Payload -> Cmd msg`, sends its record payload, and the record comes back unchanged through an incoming port.
  • elm / PortPipeRecordTest
    A JSON object received at a record type goes out with exactly the record's fields.

Discussions

Discuss this rule·Search the discussions on GitHub

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