;; 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}
