Elm Exactly

Rule 155e-dec-int

DecodingDecτ(j)=v\Dec{\tau}(j)=v
j∈IntRangeDecInt(j)=j\frac{\begin{array}{c}j\in\IntRange\end{array}}{\begin{array}{c}\Dec{\tInt}(j)=j\end{array}}
(155)
Read it in its chapter·Permanent address: /standard/rules/e-dec-int

Comments

A JSON number is an Int exactly when it is an integer within IntRange\IntRange: 1.0 and -0 decode as 1 and 0, while 1.5, and an integer outside IntRange\IntRange, do not decode. Since IntRange\IntRange is a parameter of the implementation, so is the set of numbers a port of type Int accepts (Appendix E).

TeX source
\defnrule[r:e-dec-int]
  {j\in\IntRange}
  {\Dec{\tInt}(j)=j}

Tests (6)

  • elm / MinimalPipeIntTest
    A pipe at `Int`: the value the driver sends in comes back out.
  • elm / PortEchoTest
    An `Int` sent out through an outgoing port 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.
  • elm / PortPipeRejectTest
    Values that do not decode at an incoming port's type are rejected, and the program goes on.
  • elm / PortPipeScalarsTest
    JSON numbers, Booleans, strings and `null` received at `Float`, `Int`, `Bool`, `String` and `()` go out as they came.
  • elm / PortPipeTupleTest
    A JSON array received at a tuple type goes out with as many elements as the tuple has.

Discussions

Discuss this rule·Search the discussions on GitHub

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