1 -- !!! Test file positioning
3 module Main(main) where
8 import Directory (removeFile, doesFileExist)
11 hIn <- openFile "io008.in" ReadMode
12 f <- doesFileExist "io008.out"
13 when f (removeFile "io008.out")
14 hOut <- openFile "io008.out" ReadWriteMode
19 hSeek hOut AbsoluteSeek 0
20 stuff <- hGetContents hOut
23 copy :: Handle -> Handle -> IO ()
25 try (hGetChar hIn) >>=
26 either (\ err -> if isEOFError err then return () else error "copy")
27 ( \ x -> hPutChar hOut x >> copy hIn hOut)