Rule 46sm-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 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 of the declarations of the module alone; hence a module never exposes what it imports. The set 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 , and , 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
- The comment on rule
dm-module(Chapter 7) - The comment on rule
p-stat-module(Chapter 9) - The comment on rule
p-program(Chapter 9)
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 / FileA 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.