Rule 112d-pat-as
Patterns
(112)
Comments
By the syntactic restrictions, is not bound by , so the modification adds a binding and replaces none.
TeX source
\defnrule[r:d-pat-as]
{\jdgv{E}{v}{\pat}{\VE/\FAIL}}
{\jdgv{E}{v}{\pat\ \kw{as}\ \var}{\VE/\FAIL+\{\var\mapsto v\}}}Tests (7)
- elm / CaseAsPatternTestAn as-pattern in a case branch, `((x :: _) as whole)`, binds both the list head and the whole list.
- 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 / LetDestructAliasTestA `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 / LetNumberAsPatternTestA tuple of number literals matched with an `as` pattern, where one part and the whole tuple are both used.
- elm / MinimalAsPatternTestA layered pattern binds the whole value to its variable.
- elm / StandardA99RecordPatternAsTestA record pattern under `as` in a `let` binding.
- elm / StandardCoreEvaluationExamplesTestSmall programs for rules of the dynamic semantics of the Core that other tests reach only in passing, and examples from the Comments of A Standard Definition of Elm?, Chapter 6.
Discussions
Discuss this rule·Search the discussions on GitHub
Discussions are on GitHub; one about this rule has [r:d-pat-as] 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.