[Haskell-cafe] A question about "monad laws"

Stefan O'Rear stefanor at cox.net
Mon Feb 11 16:34:54 EST 2008


On Mon, Feb 11, 2008 at 01:59:09PM +0000, Neil Mitchell wrote:
> Hi
> 
> > > (x >>= f) >>= g == x >>= (\v -> f v >>= g)
> >
> > Or stated another way:
> >
> > (x >>= f) >>= g == x >>= (f >>= g)
> 
> Which is totally wrong, woops.
> 
> See this page for lots of details about the Monad Laws and quite a
> nice explanation of where you use them:
> http://www.haskell.org/haskellwiki/Monad_Laws

My favorite presentation of the monad laws is associativity of Kliesli
composition:

(a1 >=> a2) x = a1 x >>= a2   -- predefined in 6.8 control.monad

-- The laws

return >=> a    = a
a >=> return    = a
a >=> (b >=> c) = (a >=> b) >=> c

Stefan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20080211/c7e25e76/attachment.bin


More information about the Haskell-Cafe mailing list