Rule 54sm-item-type
Comments
A type listed by name replaces any type of that name provided by an earlier import: after import Foo exposing (Maybe) the type constructor Maybe denotes the type of Foo, not that of the default import. For a record alias, holds its constructor, which is joined; for a custom type it is empty, so the constructors of a type are not imported by this item. A constructor cannot be imported by name: in import Maybe exposing (Just), is undefined, and no rule applies.
Referred to from
- The comment on rule
sm-typbind-record(Chapter 5)
TeX source
\defnrule[r:sm-item-type]
{I(\tycon) = (\theta, \VE) \premsep N' = \{\con \,;\, \VE(\con) = (\sigma, \isv) \text{ for some } \sigma\}}
{\jdg{\modid, I}{\tycon}{(\{\tycon\}, N')}}Tests (3)
- elm / ImportClosedTypeConstructorTestA custom type exposed without `(..)` exposes no constructor, even one spelt as the type.
- elm / ImportExposingItemsTestAn import's exposing list brings exactly its items into scope, with what the imported module's header exposes.
- 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-item-type] 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.