seq vs. pseq

Ross Paterson ross at
Mon Nov 6 12:21:04 EST 2006

On Mon, Nov 06, 2006 at 01:53:52PM +0000, Malcolm Wallace wrote:
> So the doubly bizarre thing is that, actually, `seq` does not control
> the evaluation order (which is the only valid reason for wanting to use
> it in the first place), but nevertheless it undesirably changes the
> semantics of programs such that equational reasoning no longer holds.

When I've used seq, it's to ensure that a function is strict in that
argument, and therefore has been evaluated before the function is called.
(If the language had unlifted types, I might have used those instead).
Beyond that, I don't care exactly when it was evaluated; it might be
long before, thanks to propagation of strictness information.

seq has a clear denotational semantics.  One can still do equational
reasoning with it, though there will be side conditions about whether
something is _|_ or not.  The downside is that the eta rules get such
side conditions, and polymorphic seq greatly weakens parametricity.

Apart from that, the only thing wrong with seq is its name.

More information about the Glasgow-haskell-users mailing list