@@ -25,33 +25,58 @@ import IO
2525
2626---- some basic io
2727
28+||| Output a string to stdout without a trailing newline, for any FFI
29+||| descriptor
30+putStr' : String -> IO' ffi ()
31+putStr' x = do prim_write x
32+ return ()
33+
2834||| Output a string to stdout without a trailing newline
29−putStr : String -> IO' ffi ()
30−putStr x = do prim_write x
31− return ()
35+putStr : String -> IO ()
36+putStr = putStr'
37+
38+||| Output a string to stdout with a trailing newline, for any FFI
39+||| descriptor
40+putStrLn' : String -> IO' ffi ()
41+putStrLn' x = putStr' (x ++ "\n")
3242
3343||| Output a string to stdout with a trailing newline
34−putStrLn : String -> IO' ffi ()
35−putStrLn x = putStr (x ++ "\n")
44+putStrLn : String -> IO ()
45+putStrLn = putStrLn'
46+
47+||| Output something showable to stdout, without a trailing newline, for any FFI
48+||| descriptor
49+print' : Show a => a -> IO' ffi ()
50+print' x = putStr' (show x)
3651
3752||| Output something showable to stdout, without a trailing newline
38−print : Show a => a -> IO' ffi ()
39−print x = putStr (show x)
53+print : Show a => a -> IO ()
54+print = print'
4055
41−||| Output something showable to stdout, with a trailing newline
42−printLn : Show a => a -> IO' ffi ()
43−printLn x = putStrLn (show x)
56+||| Output something showable to stdout, with a trailing newline, for any FFI
57+||| descriptor
58+printLn' : Show a => a -> IO' ffi ()
59+printLn' x = putStrLn' (show x)
4460
45−||| Read one line of input from stdin, without the trailing newline
46−getLine : IO' ffi String
47−getLine = do x <- prim_read
48− return (reverse (trimNL (reverse x)))
61+||| Output something showable to stdout, with a trailing newline
62+printLn : Show a => a -> IO ()
63+printLn = printLn'
64+
65+||| Read one line of input from stdin, without the trailing newline, for any FFI
66+||| descriptor
67+getLine' : IO' ffi String
68+getLine' = do x <- prim_read
69+ return (reverse (trimNL (reverse x)))
4970 where trimNL : String -> String
5071 trimNL str with (strM str)
5172 trimNL "" | StrNil = ""
5273 trimNL (strCons '\n' xs) | StrCons _ _ = xs
5374 trimNL (strCons x xs) | StrCons _ _ = strCons x xs
5475
76+||| Read one line of input from stdin, without the trailing newline
77+getLine : IO String
78+getLine = getLine'
79+
5580||| Write a single character to stdout
5681putChar : Char -> IO ()
5782putChar c = foreign FFI_C "putchar" (Int -> IO ()) (cast c)