@@ -9,8 +9,8 @@ import Control.IOExcept
99
1010||| The internal representation of StdIO effects
1111data StdIO : Effect where
12− PutStr : String -> sig StdIO ()
13− GetStr : sig StdIO String
12+ PutStr : String -> sig StdIO ()
13+ GetStr : sig StdIO String
1414 PutCh : Char -> sig StdIO ()
1515 GetCh : sig StdIO Char
1616
@@ -22,13 +22,13 @@ data StdIO : Effect where
2222instance Handler StdIO IO where
2323 handle () (PutStr s) k = do putStr s; k () ()
2424 handle () GetStr k = do x <- getLine; k x ()
25− handle () (PutCh c) k = do putChar c; k () ()
25+ handle () (PutCh c) k = do putChar c; k () ()
2626 handle () GetCh k = do x <- getChar; k x ()
2727
2828instance Handler StdIO (IOExcept a) where
2929 handle () (PutStr s) k = do ioe_lift $ putStr s; k () ()
3030 handle () GetStr k = do x <- ioe_lift $ getLine; k x ()
31− handle () (PutCh c) k = do ioe_lift $ putChar c; k () ()
31+ handle () (PutCh c) k = do ioe_lift $ putChar c; k () ()
3232 handle () GetCh k = do x <- ioe_lift $ getChar; k x ()
3333
3434-------------------------------------------------------------
@@ -42,13 +42,17 @@ STDIO = MkEff () StdIO
4242putStr : String -> Eff () [STDIO]
4343putStr s = call $ PutStr s
4444
45+||| Write a string to standard output, terminating with a newline.
46+putStrLn : String -> Eff () [STDIO]
47+putStrLn s = putStr (s ++ "\n")
48+
4549||| Write a character to standard output.
4650putChar : Char -> Eff () [STDIO]
4751putChar c = call $ PutCh c
4852
49−||| Write a string to standard output, terminating with a newline.
50−putStrLn : String -> Eff () [STDIO]
51−putStrLn s = putStr (s ++ "\n")
53+||| Write a character to standard output, terminating with a newline.
54+putCharLn : Char -> Eff () [STDIO]
55+putCharLn c = putStrLn (singleton c)
5256
5357||| Read a string from standard input.
5458getStr : Eff String [STDIO]
@@ -58,3 +62,10 @@ getStr = call $ GetStr
5862getChar : Eff Char [STDIO]
5963getChar = call $ GetCh
6064
65+||| Given a parameter `a` 'show' `a` to standard output.
66+print : Show a => a -> Eff () [STDIO]
67+print a = putStr (show a)
68+
69+||| Given a parameter `a` 'show' `a` to a standard output, terminating with a newline
70+printLn : Show a => a -> Eff () [STDIO]
71+printLn a = putStrLn (show a)