Restrictioncore-exhaustiveness
Exhaustiveness. In a match as above, every inhabitant of must be covered by some . Likewise, in a pattern binding and in a lambda , the pattern must cover every inhabitant of its type. The restrictions are inherited by derived forms: in a function definition , each must be exhaustive by itself. In deciding exhaustiveness, no set of special constants covers every inhabitant of , or , whatever the range of (Appendix E).
Tests (9)
- elm / CovPatternSplitTupleAndConstructorParametersMatchedByCaseTestFunctions that take a tuple or a custom-type value as their parameter and take it apart with `case`, including literal patterns (`( 0, b )`, `Q True n`) and a `Float` component.
- elm / MissingPatternsAMissingListLengthTestA `case` on a list that covers only the empty and one-element lists is rejected with a MISSING PATTERNS error.
- elm / MissingPatternsAMissingTupleShapeTestA `case` on a pair of `Bool`s with no branch for `( False, False )` is rejected with a MISSING PATTERNS error.
- elm / StandardA97MaybeNeverMissingJustTestA `case` on a `Maybe Never` must have a branch for `Just`.
- elm / StandardA97SelfOnlyTypeTestMatches on a type whose one constructor takes the type itself.
- elm / UnsafePatternAllDestructPatternsEdgeCaseCasesTestA `let` that destructures a list with `(h :: t) = [ 4, 5 ]` is rejected with an UNSAFE PATTERN error.
- elm / UnsafePatternDestructFixedListPatternLetDestructCasesTestA `let` that destructures a list with the fixed-length pattern `[ a, b ] = [ 1, 2 ]` is rejected with an UNSAFE PATTERN error.
- elm / UnsafePatternMixedNestedAliasesAsPatternCasesTestA function parameter pattern `(( { x }, (h :: _) as list ) as all)` is rejected with an UNSAFE PATTERN error.
- elm / UnsafePatternTripleNestedPatternsPatternArgCasesTestA function parameter pattern `( ( a, b ), { x, y }, h :: t )` is rejected with an UNSAFE PATTERN error.
Discussions
Discuss this restriction·Search the discussions on GitHub
Discussions are on GitHub; one about this restriction has [res:core-exhaustiveness] 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.