haskell: Phase 8 audit — hk-show-val matches Haskell 98 (precedence-based parens, no-space separators)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 50s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-06 22:27:30 +00:00
parent 685fcd11d5
commit 80d6507e57
4 changed files with 47 additions and 28 deletions

View File

@@ -584,13 +584,14 @@
result))))
(define
hk-show-val
hk-show-prec
(fn
(v)
(v p)
(let
((fv (hk-force v)))
(cond
((= (type-of fv) "number") (str fv))
((= (type-of fv) "number")
(if (and (< fv 0) (>= p 11)) (str "(" fv ")") (str fv)))
((= (type-of fv) "string") (str "\"" fv "\""))
((= (type-of fv) "boolean") (if fv "True" "False"))
((not (list? fv)) (str fv))
@@ -599,9 +600,15 @@
((= (first fv) ":")
(let
((elems (hk-collect-hk-list fv)))
(str "[" (hk-join-strs (map hk-show-val elems) ", ") "]")))
(str
"["
(hk-join-strs (map (fn (e) (hk-show-prec e 0)) elems) ",")
"]")))
((= (first fv) "Tuple")
(str "(" (hk-join-strs (map hk-show-val (rest fv)) ", ") ")"))
(str
"("
(hk-join-strs (map (fn (e) (hk-show-prec e 0)) (rest fv)) ",")
")"))
((= (first fv) "()") "()")
(:else
(let
@@ -609,14 +616,15 @@
(if
(empty? args)
cname
(str
"("
cname
" "
(hk-join-strs (map hk-show-val args) " ")
")"))))))))
(let
((s (str cname " " (hk-join-strs (map (fn (a) (hk-show-prec a 11)) args) " "))))
(if (>= p 11) (str "(" s ")") s)))))))))
;; ── Source-level convenience ────────────────────────────────
(define hk-show-val (fn (v) (hk-show-prec v 0)))
;; Eagerly build the Prelude env once at load time; each call to
;; hk-eval-expr-source copies it instead of re-parsing the whole Prelude.
(define
hk-init-env
(fn
@@ -997,8 +1005,6 @@
1))
env)))))
;; Eagerly build the Prelude env once at load time; each call to
;; hk-eval-expr-source copies it instead of re-parsing the whole Prelude.
(define
hk-bind-decls!
(fn