Rule 41s-patrow
Pattern Rows
(41)
Comments
A field of a record pattern binds the variable of its row to the type of the field. In a program the row is written as a label alone, whose equivalent form has (Appendix A); a copy made by number specialisation gives a new name and keeps (Section 6.2). The syntactic restrictions ensure . That follows, in a program, from the restriction that a binding site binds no variable twice, and in a copy from the distinct new names it gives.
TeX source
\defnrule[r:s-patrow]
{\opt{\jdg{C}{\patrow}{(\VE, \varrho)}}}
{\jdg{C}{\lab\ \kw{=}\ \var\ \opt{\kw{,}\ \patrow}}{(\{\var \mapsto (\tau, \isv)\}\opt{{}+\VE},\ \{\lab \mapsto \tau\}\opt{{}+\varrho})}}Tests (13)
- elm / MinimalRecordPatternTestA record pattern binds the field it names.
- elm / RecordRowsTestRecord expressions, record types and record patterns are rows of fields.
- 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.
Discussions
Discuss this rule·Search the discussions on GitHub
Discussions are on GitHub; one about this rule has [r:s-patrow] 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.