[Haskell-beginners] I/O

John Moore john.moore54 at gmail.com
Sun Oct 18 09:42:35 EDT 2009


Hi,
Could someone please tell me how to check this program. The problem is where
do I find the output? I laod this into ghc and it comes up OK modules
loaded: Main
gchi>

How do I now check if it works or see the result.

Program below (taken from real world haskell)
-- file: ch07/toupper-imp.hs
import System.IO
import Data.Char(toUpper)

main :: IO ()
main = do
       inh <- openFile "quux.txt" ReadMode
       outh <- openFile "output.txt" WriteMode
       mainloop inh outh
       hClose inh
       hClose outh
mainloop :: Handle -> Handle -> IO ()
mainloop inh outh =
    do ineof <- hIsEOF inh
       if ineof
           then return ()
           else do inpStr <- hGetLine inh
                   hPutStrLn outh (map toUpper inpStr)
                   mainloop inh outh
John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20091018/470b6ecc/attachment.html


More information about the Beginners mailing list