[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / misc / examples / io / io016 / Main.hs
diff --git a/ghc/misc/examples/io/io016/Main.hs b/ghc/misc/examples/io/io016/Main.hs
new file mode 100644 (file)
index 0000000..e8df7a9
--- /dev/null
@@ -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
+