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

Josef Svenningsson josef.svenningsson at gmail.com
Fri Aug 3 16:22:37 EDT 2007


On 8/3/07, Chris Smith <cdsmith at twu.net> wrote:
> Neil Mitchell <ndmitchell at gmail.com> wrote:
> > 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
>
>  into:
>
>      do return $ map (\price -> price * (1 + (<- getTax))) someNums
>
I think what Simon is worried about here is that the syntax in the
latter expression suggests that the effects of getTax will be
performed every time the lambda is applied. After all getTax appears
inside the lambda. But in fact is the side effects will only be
performed once. I agree with Simon that (<- getTax) shouldn't be
promoted outside a lambda.

Fwiw, I'm all in favor for some new piece of syntax for this problem.

Cheers,

Josef


More information about the Haskell-Cafe mailing list