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
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
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
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
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
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 -
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
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 -
[ 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
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
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
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
-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
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
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
[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
16 matches
Mail list logo