haskell: Phase 9 — error builtin raises with hk-error: prefix (+2 tests, 57/57)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 58s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-07 02:24:45 +00:00
parent 788e8682f5
commit 31308602ca
3 changed files with 93 additions and 118 deletions

View File

@@ -122,7 +122,11 @@ No OCaml changes are needed. The view type is fully representable as an SX dict.
### Phase 9 — `error` / `undefined`
- [ ] `error :: String -> a` — raises `(raise (list "hk-error" msg))` in SX.
- [x] `error :: String -> a` — raises `(raise "hk-error: <msg>")` in SX.
_Plan amended:_ SX's `apply` rewrites unhandled list raises to a string
`"Unhandled exception: <serialized>"` before any user handler sees them, so
the tag has to live in a string prefix rather than as the head of a list.
Catchers use `(index-of e "hk-error: ")` to detect.
- [ ] `undefined :: a` = `error "Prelude.undefined"`.
- [ ] Partial functions emit proper error messages: `head []`
`"Prelude.head: empty list"`, `tail []``"Prelude.tail: empty list"`,
@@ -289,6 +293,18 @@ No OCaml changes are needed. The view type is fully representable as an SX dict.
_Newest first._
**2026-05-07** — Phase 9 `error :: String -> a` raises with `hk-error:` prefix:
- Pre-existing `error` builtin was raising `"*** Exception: <msg>"` (GHC
console convention). Renamed prefix to `"hk-error: "` so the wrap-around
string SX's `apply` produces (`"Unhandled exception: \"hk-error: ...\""`)
contains a stable, searchable tag.
- Investigation confirmed that the plan's intended `(raise (list "hk-error" msg))`
format is mangled by SX `apply` to a string. Plan note added; tests use
`index-of` substring matching against the wrapped string.
- 2 new tests in `tests/eval.sx` (string and computed-message form). Suite
is 57/57. Other test suites unchanged (match 31/31, stdlib 48/48, derive
15/15, do-io 16/16, class 14/14).
**2026-05-07** — Phase 8 conformance: `showadt.hs` + `showio.hs` (both 5/5):
- `program-showadt.sx`: `deriving (Show)` on the classic `Expr = Lit | Add | Mul`
recursive ADT; tests `print` on three nested expressions and inline `show`