On Wed, 17 Sep 2008, Mitchell, Neil wrote:
I tend to use openFile, hGetContents, hClose - your initial readFile
like call should be openFile/hGetContents, which gives you a lazy
stream, and on a parse error call hClose.
I could use a function like
withReadFile :: FilePath -> (Handle -> IO a
On Thu, Sep 18, 2008 at 05:38:51PM +0200, Henning Thielemann wrote:
> On Wed, 17 Sep 2008, Mitchell, Neil wrote:
>> I tend to use openFile, hGetContents, hClose - your initial readFile
>> like call should be openFile/hGetContents, which gives you a lazy
>> stream, and on a parse error call hClose.
On Wed, Sep 17, 2008 at 6:21 AM, David Roundy <[EMAIL PROTECTED]> wrote:
>
> Eventually the garbage collector should close the file, I believe.
>
That's true, but "eventually" could be long enough to mean "never" in
practice. It's safest to assume that finalizers will not run at all, never
mind i
On Wed, 17 Sep 2008, Mitchell, Neil wrote:
Hi Henning,
I tend to use openFile, hGetContents, hClose - your initial readFile
like call should be openFile/hGetContents, which gives you a lazy
stream, and on a parse error call hClose.
Yes, this seems to be the right way. This weakness should be
On Wed, Sep 17, 2008 at 01:31:26PM +0200, Henning Thielemann wrote:
> Say I acquire a text by readFile, feed it to a lazy parser and the parser
> stops reading because of a parse error. After the parser error I won't
> fetch more characters from the text file, but readFile does not get to
> kn
On Behalf Of
> Henning Thielemann
> Sent: 17 September 2008 12:31 pm
> To: Haskell Cafe
> Subject: [Haskell-cafe] readFile and closing a file
>
>
> Say I acquire a text by readFile, feed it to a lazy parser
> and the parser stops reading because of a parse error. After
Say I acquire a text by readFile, feed it to a lazy parser and the parser
stops reading because of a parse error. After the parser error I won't
fetch more characters from the text file, but readFile does not get to
know that and cannot close the file. Actually, when encountering a parser
err