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:
@@ -246,6 +246,42 @@
|
||||
(hk-apply
|
||||
(hk-eval (nth node 1) env)
|
||||
(hk-mk-thunk (nth node 2) env)))
|
||||
((= tag "rec-update")
|
||||
(let
|
||||
((rec-val (hk-force (hk-eval (nth node 1) env)))
|
||||
(updates (nth node 2)))
|
||||
(let
|
||||
((cname (first rec-val))
|
||||
(args (rest rec-val))
|
||||
(new-args (list)))
|
||||
(begin
|
||||
(let
|
||||
((i 0))
|
||||
(for-each
|
||||
(fn
|
||||
(a)
|
||||
(let
|
||||
((fname-at-i
|
||||
(cond
|
||||
((nil? (hk-record-field-names cname)) nil)
|
||||
(:else
|
||||
(nth (hk-record-field-names cname) i)))))
|
||||
(let
|
||||
((override
|
||||
(cond
|
||||
((nil? fname-at-i) nil)
|
||||
(:else
|
||||
(hk-find-rec-pair updates fname-at-i)))))
|
||||
(begin
|
||||
(append!
|
||||
new-args
|
||||
(cond
|
||||
((nil? override) a)
|
||||
(:else
|
||||
(hk-mk-thunk (nth override 1) env))))
|
||||
(set! i (+ i 1))))))
|
||||
args))
|
||||
(cons cname new-args)))))
|
||||
((= tag "op")
|
||||
(hk-eval-op (nth node 1) (nth node 2) (nth node 3) env))
|
||||
((= tag "case") (hk-eval-case (nth node 1) (nth node 2) env))
|
||||
|
||||
Reference in New Issue
Block a user