Rule 109d-pat-con-fail
Patterns
(109)
Comments
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 / CaseCustomTypeTestA case on a custom type whose constructors carry different numbers of arguments binds those arguments in each branch.
- elm / CaseResultTestChecks that a `case` on a `Result` returns the `Ok` value, and -1 for any `Err`.
- elm / EitherTypeTestA custom type with two type parameters and one constructor for each can be built, mapped and pattern-matched.
- elm / EmbeddedNothingCaptureTestA local function that refers to a `Nothing` defined in the enclosing `let` matches it against the `Nothing` pattern.
- elm / MaybePatternMatchTestA `case` on a `Maybe` takes the `Just` branch to extract the value and the `Nothing` branch otherwise.
- elm / MinimalConstructedPatternFailTestA constructor pattern with an argument fails on another constructor.
- elm / TailRecCaseMultiBranchTypesTestA 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.