[Haskell-cafe] Monad laws

Luke Palmer lrpalmer at gmail.com
Tue Mar 2 19:02:13 EST 2010


On Tue, Mar 2, 2010 at 4:37 PM, Yitzchak Gale <gale at sefer.org> wrote:
> For this reason, I consider it a bug in GHC that return :: IO a
> is lazy.

Wait a minute...

   return undefined >>= const (return 42)
= const (return 42) undefined
= return 42

But if return undefined = undefined, then that equals;

  undefined >>= const (return 42)

Which, if IO is allowed to have effects (i.e. if putStrLn "Hello,
World" >>= const (return 42)  is to be different than return 42), must
be undefined.

Or does the former not hold in your version of the laws with strict composition?

Luke


More information about the Haskell-Cafe mailing list