Elm Exactly

Rule 46sm-module

ModulesB⊢module⇒B′,E\jdg{B}{\modm}{B', E}
B,π0⊢imports0 imports⇒πC=(TofB, ∅, env(MEofB,π))C⊢topdec⇒E,PEE⊢header⇒(modid,I)modid∉Dom (MEofB)T′=tynames E∖(TofB)B⊢header imports topdec⇒(T′,{modid↦I},PE),E\frac{\begin{array}{c}\jdg{B, \pi_0}{\imports_0\ \imports}{\pi} \premsep C = (T \of B,\ \emptyset,\ \smenv(\ME \of B, \pi)) \\ \jdg{C}{\topdec}{E, \PE} \premsep \jdg{E}{\header}{(\modid, I)} \\ \modid \notin \Dom(\ME \of B) \premsep T' = \tynames E \setminus (T \of B)\end{array}}{\begin{array}{c}\jdg{B}{\header\ \imports\ \topdec}{(T', \{\modid \mapsto I\}, \PE), E}\end{array}}
(46)
Read it in its chapter·Permanent address: /standard/rules/sm-module

Comments

The default imports are read before the imports of the module, so an import written in the module may replace a type that a default import exposes. The context CC holds only what the imports provide. The declarations of the module are added by rule (60) to the unqualified environment and never under a qualifier, so a module cannot refer to its own names by qualification: in a module M, M.x refers to an import with the qualifier M, if there is one. The header is elaborated last, in the environment EE of the declarations of the module alone; hence a module never exposes what it imports. The set T′T' holds every type name that the module generates, private types included, since an exposed value may have a type that mentions a private type. An import names a module of MEofB\ME \of B, and modid∉Dom (MEofB)\modid \notin \Dom(\ME \of B), so no module imports itself and no cycle of imports elaborates; Chapter 9 elaborates the modules of a program in an order in which each follows the modules it imports. Nothing here constrains a value named main: only the main of the main module of a program is constrained, in Chapter 9.

Referred to from

TeX source
\defnrule[r:sm-module]
  {\jdg{B, \pi_0}{\imports_0\ \imports}{\pi} \premsep C = (T \of B,\ \emptyset,\ \smenv(\ME \of B, \pi)) \\ \jdg{C}{\topdec}{E, \PE} \premsep \jdg{E}{\header}{(\modid, I)} \\ \modid \notin \Dom(\ME \of B) \premsep T' = \tynames E \setminus (T \of B)}
  {\jdg{B}{\header\ \imports\ \topdec}{(T', \{\modid \mapsto I\}, \PE), E}}

Tests (1)

  • elm / File
    A root module named like a module of a dependency crashes the compiler.

Discussions

Discuss this rule·Search the discussions on GitHub

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