Problems with working with Handles (PS)

Niels Reyngoud nreijngo@cs.uu.nl
Fri, 13 Jun 2003 10:54:18 +0200


(moderator, can you please include this mail at the bottom of my 
previous mail?)

PS: I think the next example shows pretty well what goes wrong when 
you're not closing the read-handle:

-------
test = do writeFile' "123.txt" "blaat"

     appendFile' "123.txt" " 1"
     z <- readFile' "123.txt"

     appendFile' "123.txt" " 2"
     s <- readFile' "123.txt"
         appendFile' "123.txt" " 3"
     t <- readFile' "123.txt"
         putStr ("\n\n")
     putStr (z ++ "\n" ++ s ++ "\n" ++ t)

-------

Instead of "blaat 1
                blaat 1 2
                 blaat 1 2 3"

three lines of "blaat 1 2 3" are outputted. The strange thing is that 
using "putStr z", "putStr s", and "putStr t" after each call of 
readFile' solves the problem,
but using seq (even though it's already called in the function readFile' 
in our module). before appending a new character to the file, like "seq 
z (appendFile "123.txt" "2")
doesn't work.

Best regards,
Niels Reyngoud