Re: [Haskell] Re: state of HaXml?

2007-01-11 Thread Sven Panne
Am Donnerstag, 11. Januar 2007 06:05 schrieb Samuel Bronson: Yeah, what I mean is that the garbage collector does not *look* for unreachable filehandles to close, or get run when many filehandles have been allocated. It only runs finalizers when it happens upon things with finalizers, it

Re: [Haskell] Re: state of HaXml?

2007-01-10 Thread Malcolm Wallace
Samuel Bronson [EMAIL PROTECTED] wrote: Can I just leave it hanging and rely on the garbage collector to close it in the fullness of time? Actually, hGetContents closes the handle when it gets an EOF. If it never does get EOF (because you never use all of the data), the garbage

Re: [Haskell] Re: state of HaXml?

2007-01-10 Thread Samuel Bronson
On 1/10/07, Malcolm Wallace [EMAIL PROTECTED] wrote: Samuel Bronson [EMAIL PROTECTED] wrote: Can I just leave it hanging and rely on the garbage collector to close it in the fullness of time? Actually, hGetContents closes the handle when it gets an EOF. If it never does get EOF (because

[Haskell-cafe] Re: [Haskell] Re: state of HaXml?

2007-01-10 Thread Taral
On 1/10/07, Malcolm Wallace [EMAIL PROTECTED] wrote: Actually, I'm pretty sure that most Haskell RTS implementations have a finalizer attached to all file handles. Once the file handle is no longer reachable from the program graph (even if its data has not been fully consumed), the GC will

Re: [Haskell-cafe] Re: [Haskell] Re: state of HaXml?

2007-01-10 Thread Bryan O'Sullivan
Taral wrote: For a read-only operation, this shouldn't matter, however on some platforms an open file handle can prevent deletion of the file. You'd be referring to Windows, then, where you can't rename or remove a file if someone has opened it. A partial defence against this is to pass

Re: [Haskell] Re: state of HaXml?

2007-01-09 Thread Samuel Bronson
On 1/4/07, Norman Ramsey [EMAIL PROTECTED] wrote: 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 -

Re: [Haskell] Re: state of HaXml?

2007-01-06 Thread Stefan Karrmann
My 2 cent: Why does seq not help? See code below. Simon Marlow (Thu, Jan 04, 2007 at 03:08:45PM +): and the original code was this: load fn = do handle - IO.openFile fn IO.ReadMode contents - IO.hGetContents handle IO.hClose handle return

Re: [Haskell] Re: state of HaXml?

2007-01-06 Thread Taral
On 1/4/07, Stefan Karrmann [EMAIL PROTECTED] wrote: My 2 cent: Why does seq not help? See code below. The short answer is because it only forces the head of the value, not the entire value. You need deepSeq for that. load fn = do handle - IO.openFile fn IO.ReadMode contents -

[Haskell-cafe] RE: [Haskell] Re: state of HaXml?

2007-01-05 Thread Simon Marlow
[ moving to haskell-café... ] Norman Ramsey wrote: 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

[Haskell] Re: state of HaXml?

2007-01-04 Thread Simon Marlow
Norman Ramsey wrote: 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. Thanks---I'll try it. Somehow my hoogle query missed readFile... undoubtedly because I asked for 'String - IO

Re: [Haskell] Re: state of HaXml?

2007-01-04 Thread Norman Ramsey
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

[Haskell-cafe] Re: [Haskell] Re: state of HaXml?

2007-01-04 Thread Donald Bruce Stewart
nr: 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

Re: [Haskell] Re: state of HaXml?

2006-12-30 Thread Lennart Kolmodin
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Wagner Ferenc wrote: [EMAIL PROTECTED] (Norman Ramsey) writes: load :: String - IO X.Document load fn = do handle - IO.openFile fn IO.ReadMode contents - IO.hGetContents handle IO.hClose handle

Re: [Haskell] Re: state of HaXml?

2006-12-30 Thread Norman Ramsey
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. Thanks---I'll try it. Somehow my hoogle query missed readFile... undoubtedly because I asked for 'String - IO String' instead of

Re: [Haskell] Re: state of HaXml?

2006-12-30 Thread Neil Mitchell
Hi of 'FilePath - IO String'. Dunno if this is a bug or a feature, since as far as the compiler is concerned, FilePath and String are the same type... Consider it a bug. Hoogle currently doesn't support type aliases. Version 4 will support them perfectly. As it turns out for type searching

[Haskell] Re: state of HaXml?

2006-12-27 Thread Wagner Ferenc
[EMAIL PROTECTED] (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