> There seems to be a misunderstanding here: readFile in itself is not the > solution. readFile is defined thus: > > readFile name = openFile name ReadMode >>= hGetContents > > and the original code was this: > > load fn = do handle <- IO.openFile fn IO.ReadMode > contents <- IO.hGetContents handle > IO.hClose handle > return $ XP.xmlParse fn contents > > Sure, you can replace the openFile/hGetContents pair by readFile, but the > real problem is the presence of the hClose. Removing that will solve your > problem (but note that you now have no control over when the file is > actually closed).
Can I just leave it hanging and rely on the garbage collector to close it in the fullness of time? Because of laziness, I believe there's no point in my writing the following: > load fn = do handle <- IO.openFile fn IO.ReadMode > contents <- IO.hGetContents handle > let xml = XP.xmlParse fn contents > IO.hClose handle > return xml Is that correct? Norman _______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell