Elm Exactly

Rule 182p-init

Starting a ProgramPE,τ1,j⊢prog r⇒K\jdg{\PE,\tau_1,j}{\effprog\,r}{K}
Flagsτ1(j)=v1⊢r(init) v1⇒(v,cm)Flat(cm)={ ⁣∣ c1,…,cn ∣ ⁣}0, {}, Qinit, {}⊢c1⋯cn⇒(P,Q,H)⊢r(subscriptions) v⇒sbPE,τ1,j⊢prog r⇒(0,v,nil,P,sb,Q,H)\frac{\begin{array}{c}\pgFlags{\tau_1}(j)=v_1\premsep\japp{r(\kw{init})}{v_1}{(v,\cm)}\\ \effFlat(\cm)=\effmset{\effc_1,\ldots,\effc_n}\premsep \jdg{0,\ \emptymap,\ \pgQinit,\ \emptymap}{\effc_1\cdots\effc_n}{(P,Q,H)}\\ \japp{r(\kw{subscriptions})}{v}{\sbv}\end{array}}{\begin{array}{c}\jdg{\PE,\tau_1,j}{\effprog\,r}{(0,v,\pgnil,P,\sbv,Q,H)}\end{array}}
(182)
Read it in its chapter·Permanent address: /standard/rules/p-init

Comments

The host starts a program with a boundary value jj as its flags; when the host gives no flags, jj is null\effnull. With flags of the unit type every boundary value is accepted, whereas a port of the unit type accepts only null\effnull. When Flagsτ1(j)\pgFlags{\tau_1}(j) is undefined, as for j=1.5j=1.5 with flags type Int, no rule applies, there is no configuration in which the program begins, and the program does not start; how an implementation reports this is outside the definition (Appendix E). The commands of init are dispatched, and the subscriptions computed from the initial model, before any message is handled. The empty map {}\emptymap serves here as the empty process map and the empty multiset.

TeX source
\defnrule[r:p-init]
  {\pgFlags{\tau_1}(j)=v_1\premsep\japp{r(\kw{init})}{v_1}{(v,\cm)}\\
   \effFlat(\cm)=\effmset{\effc_1,\ldots,\effc_n}\premsep
   \jdg{0,\ \emptymap,\ \pgQinit,\ \emptymap}{\effc_1\cdots\effc_n}{(P,Q,H)}\\
   \japp{r(\kw{subscriptions})}{v}{\sbv}}
  {\jdg{\PE,\tau_1,j}{\effprog\,r}{(0,v,\pgnil,P,\sbv,Q,H)}}

Tests (3)

  • elm / FlagsRecordTest
    A `Platform.worker` whose flags are a record of an `Int`, a `String` and a `Bool` receives the decoded record in `init`.
  • elm / OutgoingPortTuple3Test
    Tests that a program with an outgoing port whose payload is a 3-tuple `( String, String, List String )` compiles and runs.
  • elm / StandardA72AbsentFlagsTest
    A program given no flags starts with flags `null`: `Maybe` flags are `Nothing`.

Discussions

Discuss this rule·Search the discussions on GitHub

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