Elm Exactly

Rule 93d-valbind-pat

Value BindingsE⊢valbind⇒VE\jdg{E}{\valbind}{\VE}
E⊢exp⇒vE,v⊢atpat⇒VEE⊢atpat = exp⇒VE\frac{\begin{array}{c}\jdg{E}{\expm}{v}\premsep\jdgv{E}{v}{\atpat}{\VE}\end{array}}{\begin{array}{c}\jdg{E}{\atpat\ \kw{=}\ \expm}{\VE}\end{array}}
(93)
Read it in its chapter·Permanent address: /standard/rules/d-valbind-pat

Comments

There is no rule in which atpat\atpat, matched against vv, gives FAIL: the static semantics requires the pattern of a value binding to be exhaustive (Chapter 4).

TeX source
\defnrule[r:d-valbind-pat]
  {\jdg{E}{\expm}{v}\premsep\jdgv{E}{v}{\atpat}{\VE}}
  {\jdg{E}{\atpat\ \kw{=}\ \expm}{\VE}}

Tests (31)

  • elm / CharAstralTupleTest
    An astral `Char` (code point above 0xFFFF) in a pair and in a 3-tuple keeps its code point when read back with a tuple pattern, in a function's argument and in a destructuring `let`. How `Debug.log` prints such tuples is checked by `CharAstralTupleShowTest`.
  • elm / ClosureCaptureTupleTest
    A lambda returned from a function captures a tuple and destructures it with a `let` pattern when called.
  • elm / CovLambdaSetFunctionsDestructuredFromTuplesAndRecordsTest
    Lambdas taken out of a tuple and a record by destructuring `let` patterns, put in a list and applied in turn.
  • elm / DeepNestStressTest
    Deeply nested lists, tuples, records and `let` expressions can be built and taken apart.
  • elm / DestructCaptureTest
    A tuple pattern in a `let` inside one function does not interfere with a same-named variable in the function that calls it.
  • elm / EdgeCaseAllDestructPatternsTest
    `let` bindings destructure a tuple, a record, a tuple returned by a `case`, and an `as` pattern, and each bound name has the expected value.
  • elm / EmbeddedEmptyStringCaptureTest
    A local function that refers to an empty string defined in the enclosing `let` sees it as empty: it is equal to `""`, and the captured string it returns is `""`.
  • elm / EmbeddedNothingInTupleTest
    A tuple pattern in a `let` takes `Nothing` and `Just 42` back out of a pair, and each matches the right pattern.
  • elm / EmbeddedUnitCaptureTest
    A local function returns a tuple containing a unit value bound in the enclosing `let`, and the tuple is destructured by a pattern.
  • elm / EscapeTopLevelTupleTest
    A tuple defined as a top-level constant is destructured in a `let` pattern into its two components.
  • elm / EtaExpandStateTest
    A state monad over the function alias `St a = Int -> ( Int, a )`, with `sequence` written recursively using `andThen` and `pure`, threads its state correctly.
  • elm / FunctionValueChoiceTest
    Top-level values defined by an `if` that picks between two lambdas can be both called directly and passed to a local `foldl`, and a function returning a tuple from an `if` can be destructured.
  • elm / FunctionValuesChosenByIfCaseAndTupleTest
    Functions chosen at run time by `if`, `case` and a returned tuple are called correctly.
  • elm / LetDestructAliasTest
    A `let` destructuring with an `as` pattern binds both the parts and the whole: from `((a, b)) as pair = (1, 2)`, `pair` is `(1,2)` and `a` is 1.
  • elm / LetDestructFuncTupleTest
    A `let` destructures a pair of functions chosen by a `case`: a field accessor and a record-update lambda for the same field.
  • elm / LetDestructRecordTest
    Record patterns in `let` bindings: a single field, two fields, a subset of a record's fields (`{ p, r }` from a record that also has `q`), and a record pattern nested inside a tuple pattern.
  • elm / LetDestructTupleNestedTest
    Tuple patterns in `let` bindings: a flat pair, a pair of pairs destructured in one pattern, and a pair whose second part is bound by name and destructured by a later binding.
  • elm / LetDestructuringTest
    Tuple patterns in `let` bindings, for a pair and for a triple; the line labelled `head` logs the first element of the triple `(10, 20, 30)`.
  • elm / LssGapTupleFn
    A function stored in a tuple is taken out by destructuring and called.
  • elm / MinimalDestructuringTest
    A let definition by a tuple pattern.
  • elm / StandardA99RecordPatternAsTest
    A record pattern under `as` in a `let` binding.
  • elm / StandardA99RecordPatternBothTest
    A variable bound by a record pattern in a `let`, used at Int and at Float.
  • elm / StandardA99RecordPatternDependentTest
    A `let` definition that uses a variable bound by a record pattern.
  • elm / StandardA99RecordPatternFloatTest
    A variable bound by a record pattern in a `let`, used at Float.
  • elm / StandardA99RecordPatternFunctionTest
    A function bound by a record pattern in a `let`, applied at Int and at Float.
  • elm / StandardA99RecordPatternInTopCopyTest
    A record pattern in a `let` inside a top-level value that is itself copied.
  • elm / StandardA99RecordPatternInTupleTest
    A record pattern inside the tuple pattern of a `let` binding.
  • elm / StandardA99RecordPatternIntTest
    A variable bound by a record pattern in a `let`, used at Int.
  • elm / StandardA99RecordPatternLambdaTest
    A record pattern in a lambda inside a `let` binding that is copied.
  • elm / StandardA99RecordPatternSharedVariableTest
    Two variables of one record pattern that share one `number` type.
  • elm / StandardA99RecordPatternTwoVariablesTest
    Two variables of one record pattern, with independent `number` types, used at opposite types.

Discussions

Discuss this rule·Search the discussions on GitHub

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