Elm Exactly

Rule 72d-atexp-record

Atomic ExpressionsE⊢atexp⇒v\jdg{E}{\atexp}{v}
⟨E⊢exprow⇒r⟩E⊢{ ⟨exprow⟩ }⇒{}⟨+ r⟩\frac{\begin{array}{c}\opt{\jdg{E}{\exprow}{r}}\end{array}}{\begin{array}{c}\jdg{E}{\kw{\kwlb}\ \opt{\exprow}\ \kw{\kwrb}}{\emptymap\opt{+\,r}}\end{array}}
(72)
Read it in its chapter·Permanent address: /standard/rules/d-atexp-record
TeX source
\defnrule[r:d-atexp-record]
  {\opt{\jdg{E}{\exprow}{r}}}
  {\jdg{E}{\kw{\kwlb}\ \opt{\exprow}\ \kw{\kwrb}}{\emptymap\opt{+\,r}}}

Tests (11)

  • elm / CharAstralRecordFieldTest
    An astral `Char` (code point above 0xFFFF) in a record field keeps its code point, next to an `Int` field and after a record update, and a record holding one is equal to a record literal with the same fields.
  • elm / CovLambdaSetFunctionsInRecordsTuplesAndMaybeTest
    Functions stored in record fields, tuples and a `Maybe`, taken out again and applied.
  • elm / EmbeddedMixedConstantsTest
    A record holding `Nothing`, `[]`, `True`, `""` and `()` returns each value unchanged when its field is read.
  • elm / EmbeddedNothingInRecordTest
    A `Nothing` stored in a record field and read back with `.value` matches the `Nothing` pattern.
  • elm / MinimalRecordTest
    A record expression with one field.
  • elm / RecordAccessTest
    Dot syntax reads fields of let-bound record literals.
  • elm / RecordCreateTest
    Record literals with `Int` and `String` fields print correctly through `Debug.log`.
  • elm / RecordWithFunctionsTest
    Functions stored in record fields can be called, composed and replaced with record update.
  • elm / WideRecord33Test
    A record with 33 fields, cycling through `Int`, `Float`, `Char`, `String` and `Bool`, supports field access, record patterns, update, equality and printing.
  • elm / WideRecord40Test
    A record with 40 fields, cycling through `Int`, `Float`, `Char`, `String` and `Bool`, supports field access, record patterns, update, equality and printing.
  • elm / WideRecordPatternTest
    A record with 28 `Int` fields reads back correctly through field access, through a record pattern, and after a record update.

Discussions

Discuss this rule·Search the discussions on GitHub

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