Rule 103d-atpat-nil-fail
Atomic Patterns
(103)
Referred to from
- The comment on rule
d-pat-con-fail(Chapter 6)
TeX source
\defnrule[r:d-atpat-nil-fail]
{v\neq\kw{[]}}
{\jdgv{E}{v}{\kw{[}\ \kw{]}}{\FAIL}}Tests (5)
- elm / CaseListTestChecks that a `case` on a `List` distinguishes the empty list, a list of exactly one element (`[_]`) and any longer list (`_`).
- elm / CaseListThreeWayTestChecks 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 / MinimalNilPatternFailTestThe empty-list pattern fails on a list with an element.
- elm / RecursiveListLengthTestA self-recursive function that pattern matches on `[]` and `_ :: rest` counts the elements of lists of length 0, 3 and 5.
- elm / TailRecNestedCaseTestSelf-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.