Elm Exactly

Rule 54sm-item-type

Exposing Itemsmodid,I⊢item⇒(N,N′)\jdg{\modid, I}{\expitem}{(N, N')}
I(tycon)=(θ,VE)N′={con ; VE(con)=(σ,v) for some σ}modid,I⊢tycon⇒({tycon},N′)\frac{\begin{array}{c}I(\tycon) = (\theta, \VE) \premsep N' = \{\con \,;\, \VE(\con) = (\sigma, \isv) \text{ for some } \sigma\}\end{array}}{\begin{array}{c}\jdg{\modid, I}{\tycon}{(\{\tycon\}, N')}\end{array}}
(54)
Read it in its chapter·Permanent address: /standard/rules/sm-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, N′N' 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), I(Just)I(\kw{Just}) is undefined, and no rule applies.

Referred to from

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 / ImportClosedTypeConstructorTest
    A custom type exposed without `(..)` exposes no constructor, even one spelt as the type.
  • elm / ImportExposingItemsTest
    An import's exposing list brings exactly its items into scope, with what the imported module's header exposes.
  • elm / ImportTypeByNameLaterReplacesTest
    When 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.