Elm Exactly

Rule 113dm-module

ModulesB⊢module⇒B′,VE\jdg{B}{\modm}{B',\VE}
B⊢imports⇒EE0+E⊢topdec⇒II⊢header⇒(modid,I′)B⊢header imports topdec⇒{modid↦I′}, VEofI\frac{\begin{array}{c}\jdg{B}{\imports}{E}\premsep\jdg{E_0+E}{\topdec}{I}\premsep \jdg{I}{\header}{(\modid,I')}\end{array}}{\begin{array}{c}\jdg{B}{\header\ \imports\ \topdec}{\{\modid\mapsto I'\},\ \VE\of I}\end{array}}
(113)
Read it in its chapter·Permanent address: /standard/rules/dm-module

Comments

Here E0E_0 is the environment of Appendix D that binds the list constructor names [] and ::; every module starts from it, as its elaboration starts from π0\pi_0 (rule (46)). The top-level declarations are evaluated in E0E_0 modified by the environment that the imports give, so a name that a module declares replaces, within it, an imported name spelt alike (rule (129)). The basis {modid↦I′}\{\modid\mapsto I'\} holds only what the header exposes; the value environment VEofI\VE\of I of all the module’s own values is the second result, as in the static semantics, because Chapter 9 takes the value of main from it, and main need not be exposed. A module is evaluated once, after the modules it imports, and its top-level values are evaluated then (Chapter 9).

Referred to from

TeX source
\defnrule[r:dm-module]
  {\jdg{B}{\imports}{E}\premsep\jdg{E_0+E}{\topdec}{I}\premsep
   \jdg{I}{\header}{(\modid,I')}}
  {\jdg{B}{\header\ \imports\ \topdec}{\{\modid\mapsto I'\},\ \VE\of I}}

Tests (3)

Discussions

Discuss this rule·Search the discussions on GitHub

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