Elm Exactly

Rule 149e-enc-just

EncodingEncτ(v)=j\Enc{\tau}(v)=j
Encτ(v)=jEncτ Maybe(Just v)=j\frac{\begin{array}{c}\Enc{\tau}(v)=j\end{array}}{\begin{array}{c}\Enc{\tau\,\tMaybe}(\kw{Just}\ v)=j\end{array}}
(149)
Read it in its chapter·Permanent address: /standard/rules/e-enc-just

Comments

A Just has no encoding of its own. Hence the encoding of a Maybe value cannot tell Nothing from a Just whose argument encodes as null\effnull: in Maybe (Maybe Int), both Nothing and Just Nothing encode as null\effnull, and so do Nothing and Just () in Maybe ().

TeX source
\defnrule[r:e-enc-just]
  {\Enc{\tau}(v)=j}
  {\Enc{\tau\,\tMaybe}(\kw{Just}\ v)=j}

Tests (4)

  • elm / MinimalPipeJustTest
    A pipe at `Maybe Int`: the value the driver sends in comes back out.
  • elm / PortEchoMaybeIntTest
    A `Maybe Int` sent out through a port comes back unchanged through an incoming port, for each of three sample values.
  • elm / PortEchoNestedTest
    A `List (Maybe ( Int, List String ))` sent out through a port comes back unchanged through an incoming port, for each of two sample values.
  • elm / PortPipeMaybeTest
    JSON `null` and other values received at `Maybe` types go out as they came.

Discussions

Discuss this rule·Search the discussions on GitHub

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