Elm Exactly

Rule 87d-match-next

MatchesE,v⊢match⇒v′/FAIL\jdgv{E}{v}{\match}{v'/\FAIL}
E,v⊢mrule⇒FAILE,v⊢match⇒v′/FAILE,v⊢mrule ; match⇒v′/FAIL\frac{\begin{array}{c}\jdgv{E}{v}{\mrule}{\FAIL}\premsep\jdgv{E}{v}{\match}{v'/\FAIL}\end{array}}{\begin{array}{c}\jdgv{E}{v}{\mrule\ \kw{;}\ \match}{v'/\FAIL}\end{array}}
(87)
Read it in its chapter·Permanent address: /standard/rules/d-match-next
TeX source
\defnrule[r:d-match-next]
  {\jdgv{E}{v}{\mrule}{\FAIL}\premsep\jdgv{E}{v}{\match}{v'/\FAIL}}
  {\jdgv{E}{v}{\mrule\ \kw{;}\ \match}{v'/\FAIL}}

Tests (17)

  • elm / BoolAndTest
    The `&&` operator gives `True` only when both operands are `True`, checked over all four combinations.
  • elm / BoolOrTest
    The `||` operator gives `False` only when both operands are `False`, checked over all four combinations.
  • elm / CaseManyBranchesTest
    Checks that a `case` on an `Int` with seven literal branches and a wildcard selects the first, a middle and the last literal branch correctly.
  • 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 / EmbeddedNilRecursiveTest
    A recursive function that returns `[]` for an empty list builds the doubled positive elements of its input, skipping the rest.
  • elm / EqualityStringChainCaseTest
    A `case` on a `( String, Bool )` tuple with string-literal patterns selects the right branch, and direct `==` on strings gives the right answer, in the same module.
  • elm / HigherOrderFilterLikeFunctionTest
    A let-bound function that takes a predicate and a list, and keeps the list's head when the predicate holds, gives `[1]` for a predicate that always returns `True`.
  • elm / InlineDupLetNamesTest
    A function whose body does a `case` on a tuple of its arguments gives the right result when one call to it is passed as an argument to another.
  • elm / LargeDispatchCaseTest
    Checks a `case` on a list of custom-type values whose branches contain a nested `case` on a String.
  • elm / MaybePatternMatchTest
    A `case` on a `Maybe` takes the `Just` branch to extract the value and the `Nothing` branch otherwise.
  • elm / MinimalCaseNextRuleTest
    A value the first rule of a case does not match goes to the next rule.
  • elm / NestedCaseReturnTest
    A `case` on a custom type whose branches return the result of another `case` on a String, either inline or through a helper, returns the right string.
  • elm / StringCasePatternCommaTest
    Two `case` expressions on Strings, one of whose patterns contains a comma, each match against their own patterns.
  • elm / TailRecBoolCarryTest
    A self tail-recursive function that carries a `Bool` argument from one call to the next, and sets it from a branch inside a `case`, returns the right result.
  • elm / WrapperUnionFieldTest
    A single-constructor custom type can wrap a record whose field is itself a custom type, and a nested `case` reads the payload of that field.
  • elm-core / EqualityBoolIfTest
    The result of `==` and `/=` on `Bool` operands drives an `if` expression correctly.
  • elm-core / NotEqualBoolIfTest
    The result of `/=` on two `Bool` literals is used as the condition of an `if`, for all four combinations of operands; each logs `"yes"` exactly when the operands differ.

Discussions

Discuss this rule·Search the discussions on GitHub

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