Elm Exactly

Rule 60sm-topdec-seq

Top-level DeclarationsC⊢topdec⇒E,PE\jdg{C}{\topdec}{E, \PE}
C⊢topdec1⇒E1,PE1C⊕E1⊢topdec2⇒E2,PE2the separator is not one of a type-declaration phraseC⊢topdec1 ; topdec2⇒E1+E2, PE1+PE2\frac{\begin{array}{c}\jdg{C}{\topdec_1}{E_1, \PE_1} \premsep \jdg{C \oplus E_1}{\topdec_2}{E_2, \PE_2} \\ \text{the separator is not one of a type-declaration phrase}\end{array}}{\begin{array}{c}\jdg{C}{\topdec_1\ \kw{;}\ \topdec_2}{E_1 + E_2,\ \PE_1 + \PE_2}\end{array}}
(60)
Read it in its chapter·Permanent address: /standard/rules/sm-topdec-seq

Comments

Each declaration is elaborated in a context that contains the declarations before it. A type-declaration phrase, whose parts are separated by ; too, is not split: rule (57) elaborates it as a whole, so that a custom type sees the aliases that follow it. CC, a declaration of the module replaces an imported binding of the same identifier, or makes an ambiguous one available. The syntactic restrictions ensure that Dom E1∩Dom E2=∅\Dom E_1 \cap \Dom E_2 = \emptyset and Dom PE1∩Dom PE2=∅\Dom\PE_1 \cap \Dom\PE_2 = \emptyset.

Referred to from

TeX source
\defnrule[r:sm-topdec-seq]
  {\jdg{C}{\topdec_1}{E_1, \PE_1} \premsep \jdg{C \oplus E_1}{\topdec_2}{E_2, \PE_2} \\ \text{the separator is not one of a type-declaration phrase}}
  {\jdg{C}{\topdec_1\ \kw{;}\ \topdec_2}{E_1 + E_2,\ \PE_1 + \PE_2}}

Tests (10)

  • elm / ClosureCapture03Test
    A lambda returned from a function captures a value of a two-constructor custom type, both of whose constructors carry a payload, and matches on it with `case` when called.
  • elm / FunctionBasicTest
    Simple unannotated top-level functions of one and two arguments return the right values.
  • elm / IndirectCallFloatTest
    Functions of type `Float -> Float` passed to higher-order functions, including one built with `>>`, return the right Float values.
  • elm / ListIndexedMapTest
    Top-level definitions named `map2`, `range` and `length` take precedence over the same names exposed by `import List exposing (..)`.
  • elm / StandardA98TypeBeforeAliasStringMismatchTest
    A custom type declared before a local alias spelt like an imported type uses the local alias.
  • elm / StandardA98TypeBeforeAliasTest
    A custom type may mention a local alias declared after it, even one spelt like an imported type.
  • elm / TypeMismatchAliasNamedLikeAnImportedTypeTest
    A local type alias that shadows an imported type name is a different type from it, so mixing the two is rejected with a TYPE MISMATCH.
  • elm / TypeMismatchImportedTypeNamedLikeAnAliasTest
    The compiler rejects a list holding both `Basics.True` and a value of a local alias named `Bool`, which stands for `Int`, with a TYPE MISMATCH error.
  • elm / TypeMismatchLocalTypeNamedLikeAnImportedOneTest
    A local type named `Maybe` is a different type from the core `Maybe`, so mixing them is rejected with a TYPE MISMATCH.
  • elm / UserBoolNamedCtorTest
    A custom type may name its own constructors `True` and `False`, and they behave as ordinary constructors, distinct from each other and from `Unknown`.

Discussions

Discuss this rule·Search the discussions on GitHub

Discussions are on GitHub; one about this rule has [r:sm-topdec-seq] 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.