Rule 48sm-imports-import
Comments
Every identifier that the module exposes becomes available under the qualifier , and the identifiers listed by the exposing list become available unqualified. With as, the qualifier is instead of : after import Dict as D the identifier Dict.empty is not available through this import. Several imports may share a qualifier; their identifiers are joined under it, and an identifier exposed under one qualifier by two modules is ambiguous. Since the imports are read from left to right, a later import replaces what an earlier one provides for the identifiers in its . A module that is not in cannot be imported.
Referred to from
TeX source
\defnrule[r:sm-imports-import]
{(\ME \of B)(\modid) = I \premsep \pi_1 = \pi \smmerge_{\modid} (\emptyset,\ \modid''.\Dom I) \\ \optt{\jdg{\modid, I}{\explist}{(N, N')}} \premsep \pi_2 = \pi_1\ \optt{{}\smmerge_{\modid} (N, N')} \\ \jdg{B, \pi_2}{\imports}{\pi'}}
{\jdg{B, \pi}{\kw{import}\ \modid\ \opt{\kw{as}\ \modid'}\ \optt{\kw{exposing}\ \explist}\ \imports}{\pi'}}Tests (4)
- elm / CompilerIssue2119MutualRecursionUnannotatedTestAn exposed, unannotated, mutually recursive function used from another module compiles and runs.
- elm / CovForeignTypesTestChecks 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.
- elm / ImportResolutionQualifiedImportedFunctionTestA call written with the module qualifier, `Basics.negate`, resolves to the imported function even though the module is also imported with `exposing (..)`.
- elm / ImportTypeByNameLaterReplacesTestWhen two imports expose a type of the same name by name, the later import's type is the one the name denotes: the name is not ambiguous.
Discussions
Discuss this rule·Search the discussions on GitHub
Discussions are on GitHub; one about this rule has [r:sm-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.