1ce01b2d45874798dab8a421da222cf4c0f95d2b
[ghc-hetmet.git] / ghc / misc / examples / io / io016 / Main.hs
1 import IO -- 1.3
2
3 import System (getArgs)
4 import Char   (toUpper)
5
6 main   =  getArgs                           >>=        \ [f1,f2] ->
7           openFile f1 ReadMode              >>=        \ h1      ->
8           openFile f2 WriteMode             >>=        \ h2      ->
9           copyFile h1 h2                    >>
10           hClose h1                         >>
11           hClose h2
12
13 copyFile h1 h2 =
14           hIsEOF h1                         >>=        \ eof ->
15           if eof then
16             return ()
17           else
18             hGetChar h1                     >>=        \ c       ->
19             hPutChar h2 (toUpper c)         >>
20             copyFile h1 h2
21