
On Tue, Jun 22, 2004 at 02:37:38PM +0100, Malcolm Wallace wrote:
"Simon Peyton-Jones"
writes: | That contradicts my intution for seq. I would read it as "h is forced | before h is forced", and I would think that (h `seq` h) is equivalent | to h. | | Were I am wrong?
You're not wrong -- Malcolm is. The function is certainly strict in h, and GHC finds it.
Well, it is certainly the case that in a denotational sense the function is strict in h, because if h is bottom, the result is bottom.
But my operational understanding is that h is a projection, that is, it is passed from argument to result unmodified. The demand on h comes from the caller of the present function, which may or may not be strict in that result. Thus, the function code itself here does not force the evaluation of h.
The point is that, because the function is strict, its implementation may force the evaluation of h, if it so chooses. This is up to the compiler, and as Simon pointed out, it actually does force h when compiling with optimization. Greetings, Carsten -- Carsten Schultz (2:38, 33:47), FB Mathematik, FU Berlin http://carsten.codimi.de/ PGP/GPG key on the pgp.net key servers, fingerprint on my home page.