diff options
Diffstat (limited to 'ghc/misc/examples/io/io016/Main.hs')
-rw-r--r-- | ghc/misc/examples/io/io016/Main.hs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/ghc/misc/examples/io/io016/Main.hs b/ghc/misc/examples/io/io016/Main.hs new file mode 100644 index 0000000000..e8df7a93dd --- /dev/null +++ b/ghc/misc/examples/io/io016/Main.hs @@ -0,0 +1,18 @@ +import LibSystem (getArgs) + +main = getArgs >>= \ [f1,f2] -> + openFile f1 ReadMode >>= \ h1 -> + openFile f2 WriteMode >>= \ h2 -> + copyFile h1 h2 >> + hClose h1 >> + hClose h2 + +copyFile h1 h2 = + hIsEOF h1 >>= \ eof -> + if eof then + return () + else + hGetChar h1 >>= \ c -> + hPutChar h2 (toUpper c) >> + copyFile h1 h2 + |