Elm Exactly

Rule 103d-atpat-nil-fail

Atomic PatternsE,v⊢atpat⇒VE/FAIL\jdgv{E}{v}{\atpat}{\VE/\FAIL}
v≠[]E,v⊢[ ]⇒FAIL\frac{\begin{array}{c}v\neq\kw{[]}\end{array}}{\begin{array}{c}\jdgv{E}{v}{\kw{[}\ \kw{]}}{\FAIL}\end{array}}
(103)
Read it in its chapter·Permanent address: /standard/rules/d-atpat-nil-fail

Referred to from

TeX source
\defnrule[r:d-atpat-nil-fail]
  {v\neq\kw{[]}}
  {\jdgv{E}{v}{\kw{[}\ \kw{]}}{\FAIL}}

Tests (5)

  • elm / CaseListTest
    Checks that a `case` on a `List` distinguishes the empty list, a list of exactly one element (`[_]`) and any longer list (`_`).
  • elm / CaseListThreeWayTest
    Checks that a `case` on a `List` with `[]`, `[x]` and `x :: xs` patterns, in that order, sends a one-element list to `[x]` rather than to the cons pattern.
  • elm / MinimalNilPatternFailTest
    The empty-list pattern fails on a list with an element.
  • elm / RecursiveListLengthTest
    A self-recursive function that pattern matches on `[]` and `_ :: rest` counts the elements of lists of length 0, 3 and 5.
  • elm / TailRecNestedCaseTest
    Self-recursive list functions whose tail call sits in an `if` branch or behind a `case` with several list patterns return the right results.

Discussions

Discuss this rule·Search the discussions on GitHub

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