haskell: Phase 9 — undefined in prelude + lazy CAFs (+2 tests, 59/59)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m7s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-07 03:00:29 +00:00
parent 31308602ca
commit 51f57aa2fa
3 changed files with 30 additions and 6 deletions

View File

@@ -247,6 +247,18 @@
false))
true)
(hk-test
"undefined: raises hk-error with Prelude.undefined message"
(guard
(e (true (>= (index-of e "hk-error: Prelude.undefined") 0)))
(begin (hk-deep-force (hk-run "main = undefined")) false))
true)
(hk-test
"undefined: lazy — only fires when forced"
(hk-deep-force (hk-run "main = if True then 42 else undefined"))
42)
(hk-test
"second arg never forced"
(hk-eval-expr-source "(\\x y -> x) 1 (error \"never\")")
@@ -257,30 +269,30 @@
(hk-eval-expr-source "(\\x y -> y) (error \"never\") 99")
99)
;; ── not / id built-ins ──
(hk-test
"constructor argument is lazy under wildcard pattern"
(hk-eval-expr-source
"case Just (error \"deeply\") of Just _ -> 7 ; Nothing -> 0")
7)
(hk-test
"lazy: const drops its second argument"
(hk-prog-val "const x y = x\nresult = const 5 (error \"boom\")" "result")
5)
;; ── not / id built-ins ──
(hk-test
"lazy: head ignores tail"
(hk-prog-val
"myHead (x:_) = x\nresult = myHead (1 : (error \"tail\") : [])"
"result")
1)
(hk-test
"lazy: Just on undefined evaluates only on force"
(hk-prog-val
"wrapped = Just (error \"oh no\")\nresult = case wrapped of Just _ -> True ; Nothing -> False"
"result")
(list "True"))
(hk-test "not True" (hk-eval-expr-source "not True") (list "False"))
(hk-test "not False" (hk-eval-expr-source "not False") (list "True"))