seq vs. pseq
Ross Paterson
ross at soi.city.ac.uk
Mon Nov 6 13:57:43 EST 2006
On Mon, Nov 06, 2006 at 06:25:48PM +0000, Malcolm Wallace wrote:
> When I use `seq`, it is sometimes in a construction like
>
> unsafePerformIO (emit "squawk!) `seq` x
>
> where I am trying to force the impure side-effect to happen, exactly and
> immediately before x is evaluated. Whilst this is not good style in a
> general sense, I argue that it is perfectly safe inside certain kinds of
> library (e.g. for calculating coverage information, or for emitting
> tracing information). But if the language itself cannot guarantee this
> exact placement of side-effects, then it becomes impossible to write
> computation-reflective tools like Hat and hpc for Haskell, in Haskell.
> That would surely be a sad state of affairs.
Without admitting the existence of "unsafePerformIO", I submit
unsafePerformIO (emit "squawk! >> return x)
where >> really does imply sequencing.
More information about the Glasgow-haskell-users
mailing list