Elm Exactly

Rule 166e-dec-tuple

DecodingDecτ(j)=v\Dec{\tau}(j)=v
n≥kk=2⟨+1⟩Decτ1(j1)=v1Decτ2(j2)=v2⟨Decτ3(j3)=v3⟩Dec(τ1,τ2⟨,τ3⟩) Tuplek([j1,…,jn])=(v1,v2⟨,v3⟩)\frac{\begin{array}{c}n\geq k\premsep k=2\opt{{}+1}\\ \Dec{\tau_1}(j_1)=v_1\premsep\Dec{\tau_2}(j_2)=v_2\premsep \opt{\Dec{\tau_3}(j_3)=v_3}\end{array}}{\begin{array}{c}\Dec{(\tau_1,\tau_2\opt{,\tau_3})\,\tTuple{k}}(\effJarr{j_1,\ldots,j_n}) =(v_1,v_2\opt{,v_3})\end{array}}
(166)
Read it in its chapter·Permanent address: /standard/rules/e-dec-tuple

Comments

An array longer than the tuple is accepted, and its further elements are ignored; a shorter array does not decode.

TeX source
\defnrule[r:e-dec-tuple]
  {n\geq k\premsep k=2\opt{{}+1}\\
   \Dec{\tau_1}(j_1)=v_1\premsep\Dec{\tau_2}(j_2)=v_2\premsep
   \opt{\Dec{\tau_3}(j_3)=v_3}}
  {\Dec{(\tau_1,\tau_2\opt{,\tau_3})\,\tTuple{k}}(\effJarr{j_1,\ldots,j_n})
   =(v_1,v_2\opt{,v_3})}

Tests (5)

  • elm / MinimalPipeTupleTest
    A pipe at `( Int, Int )`: the value the driver sends in comes back out.
  • 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 / PortEchoTuple2Test
    A `( Int, String )` sent out through an outgoing port comes back unchanged through an incoming port.
  • elm / PortEchoTuple3Test
    A `( Int, Float, Bool )` sent out through an outgoing port comes back unchanged through an incoming port.
  • 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-tuple] 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.