Elm Exactly

Rule 59sm-topdec-portin

Top-level DeclarationsC⊢topdec⇒E,PE\jdg{C}{\topdec}{E, \PE}
U is new for ty in CC+U⊢ty⇒ττ=(τ′→α)→α SubPort(τ′)C⊢port var : ty⇒{var↦(ClosCτ,v)} in Env, {var↦(in,τ′)}\frac{\begin{array}{c}U \text{ is new for } \ty \text{ in } C \premsep \jdg{C + U}{\ty}{\tau} \\ \tau = (\tau' \rightarrow \alpha) \rightarrow \alpha\,\sbtSub \premsep \Port(\tau')\end{array}}{\begin{array}{c}\jdg{C}{\kw{port}\ \var\ \kw{:}\ \ty}{\{\var \mapsto (\Clos_C \tau, \isv)\}\ \text{in}\ \Env,\ \{\var \mapsto (\smdirin, \tau')\}}\end{array}}
(59)
Read it in its chapter·Permanent address: /standard/rules/sm-topdec-portin

Comments

The variable α\alpha occurs in both places, so port recv : (Int -> a) -> Sub b does not elaborate. As for an outgoing port, port recv : (Json.Decode.Value -> msg) -> Sub msg elaborates, and port recv : (Result String Int -> msg) -> Sub msg does not.

TeX source
\defnrule[r:sm-topdec-portin]
  {U \text{ is new for } \ty \text{ in } C \premsep \jdg{C + U}{\ty}{\tau} \\ \tau = (\tau' \rightarrow \alpha) \rightarrow \alpha\,\sbtSub \premsep \Port(\tau')}
  {\jdg{C}{\kw{port}\ \var\ \kw{:}\ \ty}{\{\var \mapsto (\Clos_C \tau, \isv)\}\ \text{in}\ \Env,\ \{\var \mapsto (\smdirin, \tau')\}}}

Tests (10)

Discussions

Discuss this rule·Search the discussions on GitHub

Discussions are on GitHub; one about this rule has [r:sm-topdec-portin] 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.