
5 May
2008
5 May
'08
12:30 a.m.
Hello,
On Sat, May 3, 2008 at 3:56 AM, apfelmus
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.
From the monad law we can conclude only that "(>>= return)" is strict, not (>>=) in general. For example, (>>=) for the reader monad is not strict in its first argument:
m >>= f = \r -> f (m r) r So, "(undefined >> return 2) = (return 2)" -Iavor