Elm Exactly

Rule 115dm-imports-import

ImportsB⊢imports⇒E\jdg{B}{\imports}{E}
B(modid)=I⟨I⊢explist⇒I′⟩B⊢imports⇒EB⊢import modid as modid′ ⟨exposing explist⟩ imports⇒({modid′↦({},VEofI)}, {}⟨+ VEofI′⟩)⊞E\frac{\begin{array}{c}B(\modid)=I\premsep\opt{\jdg{I}{\explist}{I'}}\premsep \jdg{B}{\imports}{E}\end{array}}{\begin{array}{c}B\vdash\kw{import}\ \modid\ \kw{as}\ \modid'\ \opt{\kw{exposing}\ \explist}\ \imports\\ \Rightarrow(\{\modid'\mapsto(\emptymap,\VE\of I)\},\ \emptymap\opt{+\,\VE\of I'})\dmmerge E\end{array}}
(115)
Read it in its chapter·Permanent address: /standard/rules/dm-imports-import

Comments

B(modid)B(\modid) is defined, since a module is evaluated only after every module it imports (Chapter 9). The qualifier modid′\modid' gives access to every value that the imported module exposes, its constructors included; the exposing list makes a part of them available unqualified. The environment of later imports stands on the right of ⊞\dmmerge, so a name exposed by a later import replaces the same name exposed by an earlier one, and in particular a written import replaces a default import. Where elaboration has found an unqualified name ambiguous, the name is not used, so which binding is kept is immaterial.

TeX source
\defnrule[r:dm-imports-import]
  {B(\modid)=I\premsep\opt{\jdg{I}{\explist}{I'}}\premsep
   \jdg{B}{\imports}{E}}
  {B\vdash\kw{import}\ \modid\ \kw{as}\ \modid'\
     \opt{\kw{exposing}\ \explist}\ \imports\\
   \Rightarrow(\{\modid'\mapsto(\emptymap,\VE\of I)\},\ \emptymap\opt{+\,\VE\of I'})\dmmerge E}

Tests (1)

  • elm / CovForeignTypesTest
    Checks the use of two values from another module of the same project: `secretValue`, whose annotation names a type alias that its module does not expose, and a field of `config`, read through the module name as `CovForeignTypesHelper.config.x`. Their sum, 42, is logged.

Discussions

Discuss this rule·Search the discussions on GitHub

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