Files
rose-ash/lib/haskell/tests/program-showio.sx
giles 788e8682f5
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 1m0s
haskell: Phase 8 conformance — showadt.hs + showio.hs (both 5/5)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-07 01:35:38 +00:00

37 lines
1.1 KiB
Plaintext

;; showio.hs — `print` on various types inside a `do` block.
;;
;; Exercises Phase 8 `print x = putStrLn (show x)` and the IO monad's
;; statement sequencing. Each `print` produces one io-line.
(define
hk-showio-source
"main = do\n print 42\n print True\n print False\n print [1,2,3]\n print (1, 2)\n print (Just 5)\n print Nothing\n print \"hello\"\n")
(hk-test
"showio.hs — main produces 8 lines, all show-formatted"
(hk-run-io hk-showio-source)
(list "42" "True" "False" "[1,2,3]" "(1,2)" "Just 5" "Nothing" "\"hello\""))
(hk-test
"showio.hs — print Int alone"
(hk-run-io "main = print 42")
(list "42"))
(hk-test
"showio.hs — print list of Maybe"
(hk-run-io "main = print [Just 1, Nothing, Just 3]")
(list "[Just 1,Nothing,Just 3]"))
(hk-test
"showio.hs — print nested tuple"
(hk-run-io "main = print ((1, 2), (3, 4))")
(list "((1,2),(3,4))"))
(hk-test
"showio.hs — print derived ADT inside do"
(hk-run-io
"data Color = Red | Green | Blue deriving (Show)\nmain = do { print Red; print Green; print Blue }")
(list "Red" "Green" "Blue"))
{:fails hk-test-fails :pass hk-test-pass :fail hk-test-fail}