[Haskell-cafe] Re: Control.Exception.evaluate - 'correct
definition' not so correct
iavor.diatchki at gmail.com
Sun May 4 20:30:37 EDT 2008
On Sat, May 3, 2008 at 3:56 AM, apfelmus <apfelmus at quantentunnel.de> 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.
>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)"
More information about the Haskell-Cafe