[Haskell-cafe] Re: monad subexpressions

Neil Mitchell ndmitchell at gmail.com
Fri Aug 3 14:52:02 EDT 2007


> >     do { do { a; b}; c }
> >
> > is still the same as
> >
> >     do { a; do { b; c } }
> >
> > yes? no? perhaps? sometimes? how long did it take you?
> I'm not entirely sure I understand the point here.  The monad laws are
> defined in terms of >>= and return.  They have never had anything to do
> with do, let, or <-.  All of the monad laws still hold.

The Monad laws have never been defined in terms of do notation, but
they have always held with do notation since it was simply basic sugar
for >> and >>=. Now do notation is no longer as simple, and the laws
do not hold on do, only on the desugared version. We have lost the
ability to manipulate do quite as easily, and gained a more compact
expression of monadic actions.

I think the trade off is worth it, but others may not.



More information about the Haskell-Cafe mailing list