[project @ 2000-04-25 11:27:35 by rrt]
[ghc-hetmet.git] / ghc / tests / io / should_run / io016.hs
1 import IO
2
3 import System (getArgs)
4 import Char   (toUpper)
5 import Directory (removeFile, doesFileExist)
6
7 main   =  getArgs                           >>=        \ [f1,f2] ->
8           openFile f1 ReadMode              >>=        \ h1      ->
9           doesFileExist f2                  >>=        \ f       ->
10           if f then removeFile f2 else return () >>
11           openFile f2 WriteMode             >>=        \ h2      ->
12           copyFile h1 h2                    >>
13           hClose h1                         >>
14           hClose h2
15
16 copyFile h1 h2 =
17           hIsEOF h1                         >>=        \ eof ->
18           if eof then
19             return ()
20           else
21             hGetChar h1                     >>=        \ c       ->
22             hPutChar h2 (toUpper c)         >>
23             copyFile h1 h2
24