Rule 60sm-topdec-seq
Top-level Declarations
(60)
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. , a declaration of the module replaces an imported binding of the same identifier, or makes an ambiguous one available. The syntactic restrictions ensure that and .
Referred to from
- The comment on rule
sm-module(Chapter 5) - The comment on rule
sm-topdec-types(Chapter 5)
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 / ClosureCapture03TestA 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 / FunctionBasicTestSimple unannotated top-level functions of one and two arguments return the right values.
- elm / IndirectCallFloatTestFunctions of type `Float -> Float` passed to higher-order functions, including one built with `>>`, return the right Float values.
- elm / ListIndexedMapTestTop-level definitions named `map2`, `range` and `length` take precedence over the same names exposed by `import List exposing (..)`.
- elm / StandardA98TypeBeforeAliasStringMismatchTestA custom type declared before a local alias spelt like an imported type uses the local alias.
- elm / StandardA98TypeBeforeAliasTestA custom type may mention a local alias declared after it, even one spelt like an imported type.
- elm / TypeMismatchAliasNamedLikeAnImportedTypeTestA 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 / TypeMismatchImportedTypeNamedLikeAnAliasTestThe 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 / TypeMismatchLocalTypeNamedLikeAnImportedOneTestA local type named `Maybe` is a different type from the core `Maybe`, so mixing them is rejected with a TYPE MISMATCH.
- elm / UserBoolNamedCtorTestA 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.