strict bits of datatypes

Bernie Pope bjpop at csse.unimelb.edu.au
Tue Mar 20 11:21:51 EDT 2007


Malcolm wrote:

> The Haskell Report's definition of `seq` does _not_ imply an order of
> evaluation.  Rather, it is a strictness annotation.  

That is an important point.

> Now, in the definition
>     x = x `seq` foo
> one can also make the argument that, if the value of x (on the lhs of
> the defn) is demanded, then of course the x on the rhs of the defn is
> also demanded.  There is no need for the `seq` here either.
> Semantically, the definition is equivalent to
>     x = foo
> I am arguing that, as a general rule, eliding the `seq` in such a case
> is an entirely valid and correct transformation.

I think it is possible that both camps are right on this issue, as far as
Haskell 98 stands.

We can translate the definition of x into:

x = fix (\y -> seq y foo)

Isn't it the case that, denotationally, _|_ and foo are valid
interpretations of the rhs?

If we want to choose between them then we need something extra, such as an
operational semantics, or a rule saying that we prefer the least solution.

Perhaps I am just re-stating what Ian wrote in the beginning :)

Cheers,
Bernie.



More information about the Haskell-prime mailing list