X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fmisc%2Fexamples%2Fio%2Fio016%2FMain.hs;fp=ghc%2Fmisc%2Fexamples%2Fio%2Fio016%2FMain.hs;h=e8df7a93dd0801d6a714de2ae2a174ce6edc38e1;hb=e7d21ee4f8ac907665a7e170c71d59e13a01da09;hp=0000000000000000000000000000000000000000;hpb=e48474bff05e6cfb506660420f025f694c870d38;p=ghc-hetmet.git diff --git a/ghc/misc/examples/io/io016/Main.hs b/ghc/misc/examples/io/io016/Main.hs new file mode 100644 index 0000000..e8df7a9 --- /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 +