[Haskell-cafe] [newbie] processing large logs

Antti-Juhani Kaijanaho antti-juhani at kaijanaho.fi
Sun May 14 08:25:35 EDT 2006

Eugene Crosser wrote:
> Anyway, I understand that you used 'seq' in your example as a way to
> "strictify" the function that updates accumulator.  Could you (or
> anyone) explain (in plain English, preferably:) the reason why 'seq' is
> the way it is.  In the first place, why does it have the first argument
> at all, and what should you put there?

seq returns its second argument without doing anything to it.  As a 
side-effect, it also evaluates (shallowly) its first argument.

So, first argument should be what you want to be evaluated, second is 
what you want seq to return.

Note that e `seq` e is useless; it does *not* force the evaluation of e 
before it would be evaluated in any case.

More information about the Haskell-Cafe mailing list