haskell: Phase 14 — record update r { field = v } (parser + desugar + eval)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m6s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m6s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -254,9 +254,11 @@ No OCaml changes are needed. The view type is fully representable as an SX dict.
|
||||
- [x] Record creation `Foo { bar = 1, baz = "x" }` parsed as
|
||||
`(:rec-create CON [(FNAME EXPR) …])`. Eval builds the same tagged list as
|
||||
positional construction (field order from the data decl).
|
||||
- [ ] Record update `r { field = v }` parsed as `(:rec-update EXPR [(FNAME EXPR)])`.
|
||||
- [x] Record update `r { field = v }` parsed as `(:rec-update EXPR [(FNAME EXPR)])`.
|
||||
Eval forces the record, replaces the relevant positional slot, returns a new
|
||||
tagged list. Field → index mapping stored in `hk-constructors` at registration.
|
||||
_Field map lives in `hk-record-fields` (desugar.sx) for load-order reasons,
|
||||
not `hk-constructors`._
|
||||
- [ ] Exhaustive record patterns: `Foo { bar = b }` in case binds `b`,
|
||||
wildcards remaining fields.
|
||||
- [ ] Tests in `lib/haskell/tests/records.sx` (≥ 12 tests: creation, accessor,
|
||||
@@ -313,6 +315,20 @@ No OCaml changes are needed. The view type is fully representable as an SX dict.
|
||||
|
||||
_Newest first._
|
||||
|
||||
**2026-05-07** — Phase 14 record-update syntax `r { field = v }`:
|
||||
- Parser: `varid {` after a primary expression now triggers
|
||||
`hk-parse-rec-update` returning `(:rec-update record-expr [(fname expr) …])`.
|
||||
(Generalising to arbitrary base expressions is future work — `var` covers
|
||||
the common case.)
|
||||
- Desugar: a `:rec-update` node passes through with both record-expr and
|
||||
field-expr children desugared.
|
||||
- Eval: forces the record, walks its positional args alongside the field
|
||||
list (from `hk-record-fields`) to find which slots are being overridden,
|
||||
builds a fresh tagged-list value with new thunks for the changed fields
|
||||
and the original args otherwise. Multi-field update works. Verified end-
|
||||
to-end on `alice { age = 31 }` (only age changes; name preserved). No
|
||||
regressions in eval / match / desugar suites.
|
||||
|
||||
**2026-05-07** — Phase 14 record-creation syntax `Foo { f = e, … }`:
|
||||
- Parser: post-`conid` peek for `{` triggers `hk-parse-rec-create`, returning
|
||||
`(:rec-create cname [(fname expr) …])`.
|
||||
|
||||
Reference in New Issue
Block a user