Rule 25s-ty-openrecord
Type Expressions
(25)
Comments
Only a type variable of class names a row variable, so { number | x : Int } does not elaborate.
TeX source
\defnrule[r:s-ty-openrecord]
{\tyvar = \epsilon \premsep \epsilon \in U \of C \premsep \jdg{C}{\tyrow}{\varrho}}
{\jdg{C}{\kw{\kwlb}\ \tyvar\ \kw{|}\ \tyrow\ \kw{\kwrb}}{\orec{\varrho}{\epsilon}}}Tests (10)
- elm / CompilerIssue1550RecordExtensionDuplicateFieldTestExtending a record type with a field it already has is accepted, and the field's type is replaced.
- elm / CompilerIssue2027IncompatibleExtensibleRecordsHangTestUsing one value as two incompatible extensible records (`Tricky x x`) must be a type error.
- elm / CompilerIssue2200ConstrainedExtensibleErrorCrashTestA type error for an extensible record whose row variable is the constrained `number` must be reported completely, not crash the compiler.
- elm / MinimalRowVariableTestAn annotation with an extensible record type.
- elm / RecordNarrow06RowPolyAnnotationTestA let-bound helper annotated with a nested extensible record type, folded with `List.foldl`, reads the right nested field.
- elm / TypeMismatchExtensibleRecordGivenAClosedOneTestA function annotated to return the extensible record `{ r | name : Int }` but returning the record literal `{ name = 1 }` is rejected with a TYPE MISMATCH.
- elm / TypeMismatchMisspeltFieldOfExtensibleRecordTestA function annotated to take an extensible record with fields `alpha` and `beta` that reads the misspelt field `r.alpah` is rejected with a TYPE MISMATCH error.
- elm / TypeMismatchRigidExtensionWhereClosedTestReturning an extensible record argument where the annotation says a closed record is rejected with a TYPE MISMATCH.
- elm / TypeMismatchSameRigidExtensionTestAn extensible record returned with a field of a different type than its annotation promises is rejected with a TYPE MISMATCH.
- elm / TypeMismatchTwoExtensibleRecordsTestAn extensible record returned where the annotation promises a record with a different extension variable 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-ty-openrecord] 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.