haskell: Phase 9 — hk-run-io catches errors and appends to io-lines
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m4s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-07 04:14:48 +00:00
parent 5f758d27c1
commit 1b844f6a19
3 changed files with 30 additions and 9 deletions

View File

@@ -131,7 +131,7 @@ No OCaml changes are needed. The view type is fully representable as an SX dict.
- [x] Partial functions emit proper error messages: `head []`
`"Prelude.head: empty list"`, `tail []``"Prelude.tail: empty list"`,
`fromJust Nothing``"Maybe.fromJust: Nothing"`.
- [ ] Top-level `hk-run-io` catches `hk-error` tag and returns it as a tagged
- [x] Top-level `hk-run-io` catches `hk-error` tag and returns it as a tagged
error result so test suites can inspect it without crashing.
- [ ] `hk-test-error` helper in `testlib.sx`:
`(hk-test-error "desc" thunk expected-substring)` — asserts the thunk raises
@@ -293,6 +293,19 @@ No OCaml changes are needed. The view type is fully representable as an SX dict.
_Newest first._
**2026-05-07** — Phase 9 `hk-run-io` catches errors, appends to io-lines:
- Wrapped both `hk-run-io` and `hk-run-io-with-input` in `(guard (e (true …)))`
that appends the caught exception to `hk-io-lines`. Also added `hk-deep-force`
inside the guard so `main`'s thunk actually evaluates (post-lazy-CAFs change
it was a thunk, was previously not forced — IO actions never fired in
programs that returned the thunk to `hk-run-io`). Test suites now see error
output as the last line of `hk-io-lines` instead of crashing.
- Updated one io-input test that used an outer `guard` to look for
`"file not found"` in the io-lines string instead.
- Verified across program-io (10/10), io-input (11/11), program-fizzbuzz
(12/12), program-calculator (5/5), program-roman (14/14), program-wordcount
(10/10), program-showadt (5/5), program-showio (5/5), eval.sx (64/64).
**2026-05-07** — Phase 9 partial functions emit proper error messages:
- Added empty-list catch clauses to `head`, `tail` in the prelude. Added
`fromJust`, `fromMaybe`, `isJust`, `isNothing` (the last three were missing).