Elm Exactly

Rule 109d-pat-con-fail

PatternsE,v⊢pat⇒VE/FAIL\jdgv{E}{v}{\pat}{\VE/\FAIL}
E(longcon)=conv∉{con}×ValnE,v⊢longcon atpat1⋯atpatn⇒FAIL\frac{\begin{array}{c}E(\longcon)=\con\premsep v\notin\{\con\}\times\Val^n\end{array}}{\begin{array}{c}\jdgv{E}{v}{\longcon\ \atpat_1\cdots\atpat_n}{\FAIL}\end{array}}
(109)
Read it in its chapter·Permanent address: /standard/rules/d-pat-con-fail

Comments

Rules (96), (99), (103), (109) and (111) are the only rules that give FAIL without a premise giving FAIL; every other FAIL comes from one of them.

TeX source
\defnrule[r:d-pat-con-fail]
  {E(\longcon)=\con\premsep v\notin\{\con\}\times\Val^n}
  {\jdgv{E}{v}{\longcon\ \atpat_1\cdots\atpat_n}{\FAIL}}

Tests (7)

  • elm / CaseCustomTypeTest
    A case on a custom type whose constructors carry different numbers of arguments binds those arguments in each branch.
  • elm / CaseResultTest
    Checks that a `case` on a `Result` returns the `Ok` value, and -1 for any `Err`.
  • elm / EitherTypeTest
    A custom type with two type parameters and one constructor for each can be built, mapped and pattern-matched.
  • elm / EmbeddedNothingCaptureTest
    A local function that refers to a `Nothing` defined in the enclosing `let` matches it against the `Nothing` pattern.
  • elm / MaybePatternMatchTest
    A `case` on a `Maybe` takes the `Just` branch to extract the value and the `Nothing` branch otherwise.
  • elm / MinimalConstructedPatternFailTest
    A constructor pattern with an argument fails on another constructor.
  • elm / TailRecCaseMultiBranchTypesTest
    A self tail-recursive search whose outer `case` has one branch per constructor of a custom type at the head of a list, with a nested `case` on a `String` inside one branch, finds the right element.

Discussions

Discuss this rule·Search the discussions on GitHub

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