Elm Exactly

Restrictioncore-field-selection

Stated in Section 2.10 Syntactic Restrictions, under Records.

In a field selection atexp.lab\atexp\kw{.}\lab (Appendix A), atexp\atexp is a longvar\longvar, a record, a record update, a field selection, or a phrase that begins with (: a parenthesised expression, a tuple, the unit or an operator value. A field accessor is never followed by a field selection: in .lab1.lab2\kw{.}\lab_1\kw{.}\lab_2 the second . begins a second field accessor, so the phrase is the application of .lab1\kw{.}\lab_1 to .lab2\kw{.}\lab_2. Likewise "s".x is the application of a string constant to the field accessor .x.

Read it in its chapter·Permanent address: /standard/restrictions/core-field-selection

Tests (5)

  • elm / CovForeignTypesTest
    Checks the use of two values from another module of the same project: `secretValue`, whose annotation names a type alias that its module does not expose, and a field of `config`, read through the module name as `CovForeignTypesHelper.config.x`. Their sum, 42, is logged.
  • elm / DeepNestStressTest
    Deeply nested lists, tuples, records and `let` expressions can be built and taken apart.
  • 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 / RecordNestedAccessTest
    Chained field access reads through nested record literals two and three levels deep.

Discussions

Discuss this restriction·Search the discussions on GitHub

Discussions are on GitHub; one about this restriction has [res:core-field-selection] 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.