@@ -9,8 +9,8 @@ import Control.IOExcept
10||| The internal representation of StdIO effects
10||| The internal representation of StdIO effects
11data StdIO : Effect where
11data StdIO : Effect where
12− PutStr : String -> { () } StdIO ()
12+ PutStr : String -> { () } StdIO ()
13− GetStr : { () } StdIO String
13+ GetStr : { () } StdIO String
14 PutCh : Char -> { () } StdIO ()
14 PutCh : Char -> { () } StdIO ()
15 GetCh : { () } StdIO Char
15 GetCh : { () } StdIO Char
@@ -22,13 +22,13 @@ data StdIO : Effect where
22instance Handler StdIO IO where
22instance Handler StdIO IO where
23 handle () (PutStr s) k = do putStr s; k () ()
23 handle () (PutStr s) k = do putStr s; k () ()
24 handle () GetStr k = do x <- getLine; k x ()
24 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 () ()
26 handle () GetCh k = do x <- getChar; k x ()
26 handle () GetCh k = do x <- getChar; k x ()
28instance Handler StdIO (IOExcept a) where
28instance Handler StdIO (IOExcept a) where
29 handle () (PutStr s) k = do ioe_lift $ putStr s; k () ()
29 handle () (PutStr s) k = do ioe_lift $ putStr s; k () ()
30 handle () GetStr k = do x <- ioe_lift $ getLine; k x ()
30 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 () ()
32 handle () GetCh k = do x <- ioe_lift $ getChar; k x ()
32 handle () GetCh k = do x <- ioe_lift $ getChar; k x ()
34-------------------------------------------------------------
34-------------------------------------------------------------
@@ -58,3 +58,10 @@ getStr = call $ GetStr
58getChar : { [STDIO] } Eff Char
58getChar : { [STDIO] } Eff Char
59getChar = call $ GetCh
59getChar = call $ GetCh
61+||| Given a parameter `a` 'show' `a` to standard output.
62+print : Show a => a -> { [STDIO] } Eff ()
63+print a = putStr (show a)
65+||| Given a parameter `a` 'show' `a` to a standard output, terminating with a newline
66+printLn : Show a => a -> { [STDIO] } Eff ()
67+printLn a = putStrLn (show a)