Elm Exactly

Rule 97d-atpat-var

Atomic PatternsE,v⊢atpat⇒VE/FAIL\jdgv{E}{v}{\atpat}{\VE/\FAIL}
E,v⊢var⇒{var↦v}\frac{\begin{array}{c}\end{array}}{\begin{array}{c}\jdgv{E}{v}{\var}{\{\var\mapsto v\}}\end{array}}
(97)
Read it in its chapter·Permanent address: /standard/rules/d-atpat-var

Comments

A variable pattern always binds: constructors and variables are spelt differently (Chapter 2), so no identifier status is consulted.

TeX source
\defnrule[r:d-atpat-var]
  {}
  {\jdgv{E}{v}{\var}{\{\var\mapsto v\}}}

Tests (6)

  • elm / MinimalCaseTest
    A case expression with one rule whose pattern is a variable.
  • elm / SingleCtorPairCharFloatTest
    Values are extracted correctly from two single-constructor types in one module, one wrapping a `Char` and one wrapping a `Float`.
  • elm / SingleCtorPairCharIntTest
    Values are extracted correctly from two single-constructor types in one module, one wrapping a `Char` and one wrapping an `Int`.
  • elm / SingleCtorPairIntFloatTest
    Values are extracted correctly from two single-constructor types in one module, one wrapping an `Int` and one wrapping a `Float`.
  • elm / SingleCtorPairStringIntTest
    Values are extracted correctly from two single-constructor types in one module, one wrapping a `String` and one wrapping an `Int`.
  • elm / SingleCtorPairUnitIntTest
    Pattern matching works on two single-constructor types in one module, one wrapping the unit value `()` and one wrapping an `Int`.

Discussions

Discuss this rule·Search the discussions on GitHub

Discussions are on GitHub; one about this rule has [r:d-atpat-var] 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.