Elm Exactly

Rule 7s-atexp-nil

Atomic ExpressionsC⊢atexp⇒τ\jdg{C}{\atexp}{\tau}
C⊢[ ]⇒τ List\frac{\begin{array}{c}\end{array}}{\begin{array}{c}\jdg{C}{\kw{[}\ \kw{]}}{\tau\,\tList}\end{array}}
(7)
Read it in its chapter·Permanent address: /standard/rules/s-atexp-nil

Comments

Note that τ\tau does not occur in any premise; thus [ ] has type τ List\tau\,\tList for every τ\tau.

Referred to from

TeX source
\defnrule[r:s-atexp-nil]
  {}
  {\jdg{C}{\kw{[}\ \kw{]}}{\tau\,\tList}}

Tests (6)

  • elm / EmbeddedNilCaptureTest
    A local function that refers to an empty list defined in the enclosing `let` matches it against the `[]` pattern.
  • elm / EmbeddedNilInCustomTypeTest
    An empty list stored in a custom type constructor and taken back out by a `case` is still empty, with length 0.
  • elm / EmbeddedNothingPolymorphicTest
    `Nothing`, `[]` and `""` pass unchanged through the polymorphic `identity`, the first two then also through a function with a concrete type.
  • elm / ErasedListSpecializationTest
    A polymorphic self-recursive `count : List a -> Int` gives the right length when called both on `List Int` values and on `[]`, whose element type nothing constrains.
  • elm / MinimalEmptyListTest
    The empty list is a value.
  • elm / PolyChainFoldlLikeCalled8TimesOverTupleKeyedStructureTest
    Tests a polymorphic fold-like function called eight times in a chain, each with a step function over `( List String, Global )` elements and the previous call's result as the initial value.

Discussions

Discuss this rule·Search the discussions on GitHub

Discussions are on GitHub; one about this rule has [r:s-atexp-nil] 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.