[Haskell] Re: state of HaXml?
kolmodin at dtek.chalmers.se
Sat Dec 30 05:18:20 EST 2006
-----BEGIN PGP SIGNED MESSAGE-----
Wagner Ferenc wrote:
> nr at eecs.harvard.edu (Norman Ramsey) writes:
>> load :: String -> IO X.Document
>> load fn = do handle <- IO.openFile fn IO.ReadMode
>> contents <- IO.hGetContents handle
>> IO.hClose handle
>> return $ XP.xmlParse fn contents
> Try not closing the handle before parsing.
I think it's a little more to it than that.
The parsing is performed lazily and therefore it's hard to try to close
the handle manually, even if HaXml would parse all of the file at once
(unless you force the evaluation).
The simplest thing is to use readFile (from the Prelude) instead of
using handles. readFile will take care of everything for you when the
time is right.
load fn = do
contents <- readFile fn
return $ XP.xmlParse fn contents
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
More information about the Haskell