
apfelmus wrote:
Bryan Donlan wrote:
evaluate x = (return $! x) >>= return
However, if >>= is strict on its first argument, then this definition is no better than (return $! x).
According to the monad law
f >>= return = f
every (>>=) ought to be strict in its first argument, so it indeed seems that the implementation given in the documentation is wrong.
But it is known that the monad laws only apply up to some weaker equivalence than 'seq-equivalence'. This has been discussed here countless times by people who understand it better than me. As I understand the summary the "=" sign in the monad laws mean "represent identical actions, in terms of the effects produced and the result returned". A kind of observational-equivalence for monad execution, but weaker than direct equational equivalence in the presence of seq. (Some people view this as more of a bug in "seq" than in the monad laws) Jules