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

@@ -1163,7 +1163,14 @@
(define
hk-run-io
(fn (src) (do (set! hk-io-lines (list)) (hk-run src) hk-io-lines)))
(fn
(src)
(do
(set! hk-io-lines (list))
(guard
(e (true (append! hk-io-lines (if (string? e) e (str e)))))
(hk-deep-force (hk-run src)))
hk-io-lines)))
(define hk-stdin-lines (list))
@@ -1176,7 +1183,9 @@
(begin
(set! hk-io-lines (list))
(set! hk-stdin-lines stdin-lines)
(hk-run src)
(guard
(e (true (append! hk-io-lines (if (string? e) e (str e)))))
(hk-deep-force (hk-run src)))
hk-io-lines)))
(define hk-env0 (hk-init-env))

View File

@@ -64,12 +64,11 @@
(hk-test
"readFile error on missing file"
(guard
(e (true (>= (index-of e "file not found") 0)))
(begin
(set! hk-vfs (dict))
(hk-run-io "main = readFile \"no.txt\" >>= putStrLn")
false))
(begin
(set! hk-vfs (dict))
(let
((lines (hk-run-io "main = readFile \"no.txt\" >>= putStrLn")))
(>= (index-of (str lines) "file not found") 0)))
true)
(hk-test