Elm Exactly

Rule 58sm-topdec-portout

Top-level DeclarationsC⊢topdec⇒E,PE\jdg{C}{\topdec}{E, \PE}
U is new for ty in CC+U⊢ty⇒ττ=τ′→α CmdPort(τ′)C⊢port var : ty⇒{var↦(ClosCτ,v)} in Env, {var↦(out,τ′)}\frac{\begin{array}{c}U \text{ is new for } \ty \text{ in } C \premsep \jdg{C + U}{\ty}{\tau} \\ \tau = \tau' \rightarrow \alpha\,\sbtCmd \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 (\smdirout, \tau')\}}\end{array}}
(58)
Read it in its chapter·Permanent address: /standard/rules/sm-topdec-portout

Comments

The variables of the annotation are made explicit, as for an annotated value. The argument of Cmd\sbtCmd must be a type variable, so port send : String -> Cmd Msg does not elaborate, nor does port send : Cmd msg, which has no payload, nor port send : Int -> Int -> Cmd msg. Since Port(τ′)\Port(\tau') excludes type variables, α\alpha is the only variable of τ\tau, and the closure generalises it. The type Cmd\sbtCmd is that of the initial basis; a type of a program spelt Cmd is a different type. A port is a value of status v\isv, so it is used and exposed like any other value; PE\PE records its direction and payload type, by which Chapter 8 gives it its meaning, and Chapter 9 requires the names of the ports of a program to be distinct. Thus port send : Char -> Cmd msg does not elaborate, while port send : List { id : Int, name : String } -> Cmd msg does.

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

Tests (13)

Discussions

Discuss this rule·Search the discussions on GitHub

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