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

Derek Elkins derek.a.elkins at gmail.com
Mon Feb 11 22:38:15 EST 2008


On Mon, 2008-02-11 at 13:34 -0800, Stefan O'Rear wrote:
> 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

Indeed.  The monad laws are just that the Kleisli category is actually a
category.



More information about the Haskell-Cafe mailing list