seq vs. pseq

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Tue Nov 7 08:01:46 EST 2006


Simon Marlow <simonmarhaskell at gmail.com> wrote:

> > When I use `seq`, it is sometimes in a construction like
> > 
> >     unsafePerformIO (emit "squawk!) `seq` x
> 
> My take on this kind of thing is that if you want a specific
> operational  behaviour, then you're doing something
> implementation-specific.  We shouldn't  mandate any kind of
> operational behaviour across Haskell implementations.  Yes,  I'm
> saying you can't do this portably, and it is good that you can't,
> because  it gives implementations more flexibility.

Hmmm.  I absolutely agree with the general point that Haskell should, as
much as possible, not mandate any specific operational behaviour.  But
what if I want to _observe_ or record the actual operational behaviour
of some particular implementation?  For instance, to generate a heap
profile, or a computational trace, or a coverage log, or something.  The
results may well be different for every different implementation, and I
am perfectly happy with that.  I may actually want to see the
differences.  But do you really want to say "The Haskell language
provides the programmer no mechanism to observe this"?  "Use some other
language, or some compiler-specific hack"?  To me, it is unacceptable to
be prevented from write an observational tool for a language in the
language itself.

Especially since we already have a couple of features in the language
that _do_ affect the operational behaviour.  They are warts, yes, but if
we have to have them, I want them to be genuinely useful.  We should
bite the bullet and specify in what way they affect the operational
semantics, without implying any more specific operational behaviour
elsewhere in the language.

Regards,
    Malcolm

P.S. Actually, as Ross points out, there is an implied operational
     semantics of the I/O monad.  Maybe that is where the Report needs
     to become more specific, and mandate certain behaviours.


More information about the Glasgow-haskell-users mailing list