Rule 21s-valbind-pat
Value Bindings
(21)
Comments
TeX source
\defnrule[r:s-valbind-pat]
{\jdg{C}{\atpat}{(\VE, \tau)} \premsep \jdg{C}{\expm}{\tau}}
{\jdg{C}{\atpat\ \kw{=}\ \expm}{\VE}}Tests (25)
- elm / ClosureCaptureTupleTestA lambda returned from a function captures a tuple and destructures it with a `let` pattern when called.
- elm / CovLambdaSetFunctionsDestructuredFromTuplesAndRecordsTestLambdas taken out of a tuple and a record by destructuring `let` patterns, put in a list and applied in turn.
- elm / CovTailRecPairParameterPassedUnchangedLetBoundAndRebuiltTestSelf tail-recursive functions with a pair parameter that is destructured in a `let`, then passed on unchanged, rebuilt with its components swapped, or replaced by a `let`-bound pair.
- elm / CovTailRecPairParametersSwappedAndALoopReturningALambdaTestSelf tail-recursive functions over pair parameters: one that swaps a pair's components or exchanges its two pair arguments, and one that returns a lambda in its base case.
- 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 / LetDestructNestedSingleConstructorNumberTestA `let` destructuring pattern through two nested single-constructor types reads a number literal that is then used as a Float.
- elm / LetNumberDestructureTestTwo `number` literals bound by a tuple pattern in a `let` are both used as `Float`s.
- elm / LetNumberRecordDestructureTestInteger-literal record fields bound by a let destructuring pattern are used as `Float`s: `{ lo, hi } = { lo = 30, hi = 40 }` followed by `round (lo * 1.5) + round (hi * 1.5)` logs 105.
- elm / LssGapTupleFnA function stored in a tuple is taken out by destructuring and called.
- elm / MinimalDestructuringTestA let definition by a tuple pattern.
- elm / NumberDestructFieldTestNumber literals stored in a constructor's tuple, list, record or `Maybe` field, then destructured in a `let` with a constructor pattern, take the type `Float` from how they are later used.
- elm / PolyStepLoopFloatResultTestA polymorphic state-threading loop, driven by a `Step state a` custom type, returns a `Float` result and the threaded state correctly.
- elm / StandardA99RecordPatternAsTestA record pattern under `as` in a `let` binding.
- elm / StandardA99RecordPatternBothTestA variable bound by a record pattern in a `let`, used at Int and at Float.
- elm / StandardA99RecordPatternDependentTestA `let` definition that uses a variable bound by a record pattern.
- elm / StandardA99RecordPatternFloatTestA variable bound by a record pattern in a `let`, used at Float.
- elm / StandardA99RecordPatternFunctionTestA function bound by a record pattern in a `let`, applied at Int and at Float.
- elm / StandardA99RecordPatternInTopCopyTestA record pattern in a `let` inside a top-level value that is itself copied.
- elm / StandardA99RecordPatternInTupleTestA record pattern inside the tuple pattern of a `let` binding.
- elm / StandardA99RecordPatternIntTestA variable bound by a record pattern in a `let`, used at Int.
- elm / StandardA99RecordPatternLambdaTestA record pattern in a lambda inside a `let` binding that is copied.
- elm / StandardA99RecordPatternSharedVariableTestTwo variables of one record pattern that share one `number` type.
- elm / StandardA99RecordPatternTwoVariablesTestTwo variables of one record pattern, with independent `number` types, used at opposite types.
- elm / TypeMismatchDestructureTestDestructuring the number `1` with the tuple pattern `( a, b )` in a `let` 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-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.