haskell: Phase 8 — showsPrec/showParen/shows/showString stubs (+7 tests, 7/7)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 52s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-07 00:02:55 +00:00
parent ee74a396c5
commit 39c7baa44c
3 changed files with 58 additions and 2 deletions

View File

@@ -107,7 +107,7 @@ No OCaml changes are needed. The view type is fully representable as an SX dict.
multi-constructor ADTs. Nested application arguments wrapped in parens:
if `show arg` contains a space, emit `"(" ++ show arg ++ ")"`. _Records
deferred — Phase 14._
- [ ] `showsPrec` / `showParen` stubs so hand-written Show instances compile.
- [x] `showsPrec` / `showParen` stubs so hand-written Show instances compile.
- [ ] `Read` class stub — just enough for `reads :: String -> [(a,String)]` to
type-check; no real parser needed yet.
- [ ] Tests in `lib/haskell/tests/show.sx` (≥ 12 tests: show Int, show Bool,
@@ -287,6 +287,18 @@ No OCaml changes are needed. The view type is fully representable as an SX dict.
_Newest first._
**2026-05-07** — Phase 8 `showsPrec` / `showParen` / `shows` / `showString` stubs:
- Added 5 lines to `hk-prelude-src`. `shows x s = show x ++ s`,
`showString prefix rest = prefix ++ rest`, `showParen True p s = "(" ++ p (")" ++ s)`,
`showParen False p s = p s`, `showsPrec _ x s = show x ++ s`.
- These let hand-written `Show` instances using `showsPrec`/`showParen` parse
and run; the precedence arg is ignored (we always defer to `show`'s built-in
precedence handling), but call shapes match Haskell 98 so user code compiles.
- New `lib/haskell/tests/show.sx` (7 tests). The file is intended to grow to
≥12 covering the full audit (Phase 8 ☐).
- Function composition `.` is not yet bound; tests use manual composition via
let-binding. Address in a later iteration.
**2026-05-06** — Phase 8 `deriving Show` nested constructor parens verified:
- The Phase 8 audit's precedence-based `hk-show-prec` already does the right
thing for `deriving Show`: each constructor arg is shown at prec 11, so any