
On 05 April 2006 21:02, Ben Rudiak-Gould wrote:
Andy Gill wrote:
- [various reasons for deepSeq]
You left out the one that most interests me: ensuring that there are no exceptions hiding inside a data structure.
deepSeq :: a -> b -> b
This ties demand for the (fully evaluated) normal form of an expression to demand for the WHNF of a different expression, which is a bit weird. I think it's cleaner for the primitive to be your "strict", which ties demand for the normal form of an expression to demand for the WHNF of the same expression. In fact I'd argue that "deepSeq" should not be provided at all (though of course it can be defined by the user). The analogy with seq is a bit misleading---deepSeq is a lot less symmetric than seq. The expressions (x `deepSeq` y `deepSeq` z) and (strict x `seq` strict y `seq` z) are equivalent, but only the latter makes it clear that z doesn't get fully evaluated.
Agreed - that pinpoints something that seemed a little strange to me too. strict should be the primitive; or maybe strict renamed to deepSeq. Cheers, Simon
participants (1)
-
Simon Marlow