Rule 33s-atpat-scon
Atomic Patterns
(33)
Comments
The side conditions give an integer constant the type in a pattern, never or a type variable of class ; a character or string constant has its own type. Thus case 1.5 of 1 -> 0 ; _
-> 1 does not elaborate. Floating point constants are not patterns, by the grammar.
TeX source
\defnrule[r:s-atpat-scon]
{\typeof(\scon) \succ \tau \premsep \tau \in \{\tInt, \tChar, \tString\}}
{\jdg{C}{\scon}{(\emptymap, \tau)}}Tests (8)
- 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 / MinimalConstantPatternTestA constant pattern matches the constant it spells.
- elm / TypeMismatchArgumentOfAFixedConstructorPatternTestA constructor pattern whose argument has the wrong type is rejected with a TYPE MISMATCH.
- elm / TypeMismatchConsHeadAgainstAConsTailTestA list pattern `1 :: "s" :: rest` is rejected with a TYPE MISMATCH, because it asks for a number and a `String` as elements of the same list.
- elm / TypeMismatchListEntryPatternTestA list pattern whose entries have different types is rejected with a TYPE MISMATCH.
- elm / TypeMismatchSecondCasePatternTestA `case` on a `String` whose second pattern is a `Char` literal is rejected with a TYPE MISMATCH.
- elm / TypeMismatchTailPatternTestA list pattern whose tail is a `String` literal is rejected with a TYPE MISMATCH.
- elm / TypeMismatchTupleComponentPatternTestA tuple pattern whose first component is a `String` literal, matched against a tuple of numbers, is rejected with a TYPE MISMATCH.
Discussions
Discuss this rule·Search the discussions on GitHub
Discussions are on GitHub; one about this rule has [r:s-atpat-scon] 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.