[Haskell-cafe] Re: Re: Re: monad subexpressions

Chris Smith cdsmith at twu.net
Fri Aug 3 16:01:14 EDT 2007

Neil Mitchell <ndmitchell at gmail.com> wrote:
> > Right.  In effect, as a matter of fact, the notation
> >
> >     x <- a
> >
> > would become equivalent to
> >
> >     let x = (<- a)
> Hmm, interesting. Consider:
> let x = 12
> let x = (<- x)

Okay, so the desugaring process wouldn't terminate in that case!  One 
could either: (a) try to retain the equivalence in theory, but make it 
illegal to use x in a monadic subexpression when defining x; (b) we 
could abandon my claim that they are equivalent.

> I'm not convinced either, a nice concrete example would let people
> ponder this a bit more.

I tried to provide something in my response to Simon.  Here it is again:

 One could sugar:

     do tax <- getTax
        return $ map (\price -> price * (1 + tax)) bill


     do return $ map (\price -> price * (1 + (<- getTax))) someNums

> What is nice to note is that all your answers
> to my questions matched perfectly with what I thought should happen.

That is nice.  I'm still very uncomfortable with the <- syntax (a 
complete flip for me since this morning!); and a little uneasy about the 
use of case, if, lambdas, etc.  Time to keep thinking, I guess.

I'd like to take Simon's suggestion and do a wiki page about this; but 
it should probably be on the Haskell prime wiki, no?  I'm not entirely 
clear on how to get an account there.  I could add it to HaskellWiki, 
but I think that would be the wrong place for it.

Chris Smith

More information about the Haskell-Cafe mailing list