The problem is that you're closing the file twice. When you call any
function of the getContents family, you assign to that function the
responsibility to close the file, no sooner than it is no longer needed.
Don't call hClose yourself, Bad Things will happen.
If you close the file, the
Tim Newsham:
Why can't hClose be more... um... lazy?
Lazy in what way? hGetContents already closes the OS handle when it
reaches the end of file.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
Stefan O'Rear wrote:
The problem is that you're closing the file twice. When you call any
function of the getContents family, you assign to that function the
responsibility to close the file, no sooner than it is no longer needed.
Don't call hClose yourself, Bad Things will happen.
Care to
On Fri, Jul 13, 2007 at 07:59:22PM +0100, Andrew Coppin wrote:
Stefan O'Rear wrote:
The problem is that you're closing the file twice. When you call any
function of the getContents family, you assign to that function the
responsibility to close the file, no sooner than it is no longer needed.
Stefan O'Rear wrote:
On Fri, Jul 13, 2007 at 07:59:22PM +0100, Andrew Coppin wrote:
Care to elaborate on bad things? (I.e., will this just crash the program
with an error, or will it do something more serious?) I must admit, I
thought closing such a file was simply no-op.
If you
Brandon Michael Moore wrote:
Calling hClose after hGetContents is the root of the problem, but this is
a good example for understanding seq better too.
To further this end, I'll take issue :) with the final version that
has been tested to work, and show that it still won't work.
First, the
Albert,
Thanks for the very detailed reply! That's the great thing about this mailing
list.
I find your description of seq somewhat disturbing. Is this behavior documented in the API? I
can't find it there. It suggests that perhaps there should be a
On Fri, Jul 13, 2007 at 04:29:12PM -0700, Michael Vanier wrote:
Albert,
Thanks for the very detailed reply! That's the great thing about this
mailing list.
I find your description of seq somewhat disturbing. Is this behavior
documented in the API? I can't find it there. It suggests
On 7/13/07, Stefan O'Rear [EMAIL PROTECTED] wrote:
instance Eval Int where
...
seq (-1) b = b
seq 0 b = b
seq 1 b = b
...
I don't think you need all these cases. In fact, you can write
instance Eval Int where
seq 0 b = b
seq _ b = b
which, in GHC -O2, desugars to
Stefan,
Thanks for your comments, as always.
What I meant by really-truly-absolutely-I-mean-right-now-seq is something that would evaluate its
argument as far as it is possible to do so i.e. something that forces strict evaluation of an
argument. That's what I thought seq did, but now I see
On Saturday 14 July 2007 11:29, Michael Vanier wrote:
Albert,
Thanks for the very detailed reply! That's the great thing about this
mailing list.
I find your description of seq somewhat disturbing. Is this behavior
documented in the API? I can't find it there.
As I understand it seq
On 7/13/07, Michael Vanier [EMAIL PROTECTED] wrote:
Stefan,
Thanks for your comments, as always.
What I meant by really-truly-absolutely-I-mean-right-now-seq is something that
would evaluate its
argument as far as it is possible to do so i.e. something that forces strict
evaluation of an
On 7/13/07, Michael Vanier [EMAIL PROTECTED] wrote:
What I meant by really-truly-absolutely-I-mean-right-now-seq is something that
would evaluate its
argument as far as it is possible to do so i.e. something that forces strict
evaluation of an
argument.
What you want is to reduce something
On Fri, 2007-07-13 at 17:20 -0700, Michael Vanier wrote:
Stefan,
Thanks for your comments, as always.
What I meant by really-truly-absolutely-I-mean-right-now-seq is something
that would evaluate its
argument as far as it is possible to do so i.e. something that forces strict
On Fri, Jul 13, 2007 at 09:19:58PM -0300, Felipe Almeida Lessa wrote:
On 7/13/07, Stefan O'Rear [EMAIL PROTECTED] wrote:
instance Eval Int where
...
seq (-1) b = b
seq 0 b = b
seq 1 b = b
...
I don't think you need all these cases. In fact, you can write
instance
That makes sense. Thanks!
Mike
Stefan O'Rear wrote:
On Thu, Jul 12, 2007 at 09:22:09PM -0700, Michael Vanier wrote:
I stumbled across a problem with IO and strictness that I could fix, but I
can't understand why the fix works. I've compressed it down into a program
which simply computes
On Thu, Jul 12, 2007 at 09:22:09PM -0700, Michael Vanier wrote:
I stumbled across a problem with IO and strictness that I could fix, but I
can't understand why the fix works. I've compressed it down into a program
which simply computes the number of lines in a file. Here is a version
that
I stumbled across a problem with IO and strictness that I could fix, but I can't understand why the
fix works. I've compressed it down into a program which simply computes the number of lines in a
file. Here is a version that doesn't work:
module Main where
import System.IO
import
18 matches
Mail list logo