Rule 167e-dec-record
Decoding
(167)
Comments
An object with further keys is accepted, and they are ignored; an object that lacks the key of a field does not decode. Which missing field an implementation reports, and how, is outside the definition.
TeX source
\defnrule[r:e-dec-record]
{j\in\effStr\finmap\BVal\premsep\Dom\varrho\subseteq\Dom j\premsep
\Dom r=\Dom\varrho\\
\Dec{\varrho(\lab)}(j(\lab))=r(\lab)\ \text{for each}\ \lab\in\Dom\varrho}
{\Dec{\rec{\varrho}}(j)=r}Tests (4)
- elm / FlagsRecordTestA `Platform.worker` whose flags are a record of an `Int`, a `String` and a `Bool` receives the decoded record in `init`.
- elm / MinimalPipeRecordTestA pipe at `{ a : Int }`: the value the driver sends in comes back out.
- elm / PortAliasEchoTestAn 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 / PortPipeRecordTestA 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-dec-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.