Elm Exactly

Rule 94d-atpat-wild

Atomic PatternsE,v⊢atpat⇒VE/FAIL\jdgv{E}{v}{\atpat}{\VE/\FAIL}
E,v⊢_⇒{}\frac{\begin{array}{c}\end{array}}{\begin{array}{c}\jdgv{E}{v}{\kw{\_}}{\emptymap}\end{array}}
(94)
Read it in its chapter·Permanent address: /standard/rules/d-atpat-wild
TeX source
\defnrule[r:d-atpat-wild]
  {}
  {\jdgv{E}{v}{\kw{\_}}{\emptymap}}

Tests (18)

  • elm / CaseCharManyBranchTest
    A case on Char with ten literal branches (`'0'` to `'9'`) and a wildcard maps digit characters to their values and anything else to -1.
  • elm / CaseCharTest
    A case on Char with literal vowel branches and a wildcard picks the matching literal, falling back to the wildcard for other characters.
  • elm / CaseCustomType4WildcardTest
    A case on a four-constructor custom type with two explicit branches and a wildcard sends the other two constructors to the wildcard.
  • elm / CaseDefaultTest
    A case on Int with one literal branch and a wildcard sends every other value to the wildcard.
  • elm / CaseIntTest
    Checks that a `case` on an `Int` matches integer literal patterns and falls through to the wildcard for any other value.
  • elm / CaseStringEmptyPatternTest
    A case expression on a `String` matches the empty-string literal `""` alongside non-empty literal patterns and a wildcard.
  • elm / CaseStringEscapeTest
    A case expression on a `String` matches literal patterns written with escape sequences: a newline, a tab and a double quote.
  • elm / CaseStringManyBranchTest
    A case expression on a `String` with seven literal patterns (three-letter day abbreviations) and a wildcard selects the matching branch.
  • elm / CaseStringTest
    A case expression on a `String` with two literal patterns and a wildcard returns the `Int` of the matching branch.
  • elm / CaseUnicodeCharTest
    A case expression on a `Char` matches character literals outside ASCII: two Greek letters and a CJK ideograph.
  • elm / CustomTypePatternTest
    Functions that take apart a custom-type value with a constructor pattern in their argument extract the right field.
  • elm / DecisionTreeAdvancedDeepNestingWithFallbackTest
    A `case` on a pair of pairs whose first branch matches all-zero literals and whose second binds the first and last numbers falls through to the second branch.
  • elm / HigherOrderReturnLambdaBasedOnConditionTest
    A let-bound function that returns one of two lambdas depending on a `Bool` can be applied to a further argument in the same call.
  • elm / LambdaPatternArgTest
    Checks anonymous functions whose parameters are tuple, record and wildcard patterns.
  • elm / LetNumberWildcardSlotTest
    The first and last integer literals of a three-element tuple are used as `Float`s while the middle one is matched by a wildcard: matching `( 30, 40, 50 )` against `( a, _, c )` and adding `round (a * 1.5)` to `round (c * 1.5)` logs 120.
  • elm / MinimalCaseNextRuleTest
    A value the first rule of a case does not match goes to the next rule.
  • elm / SingleCtorPairUnitIntTest
    Pattern matching works on two single-constructor types in one module, one wrapping the unit value `()` and one wrapping an `Int`.
  • elm / TailRecCaseDestructTest
    Self tail-recursive functions whose tail calls sit in a `case` branch that destructures a list with `x :: xs` give the right results.

Discussions

Discuss this rule·Search the discussions on GitHub

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