[Haskell-cafe] Re: Lambda-case / lambda-if

Miguel Mitrofanov miguelimo38 at yandex.ru
Thu Oct 7 13:36:53 EDT 2010



Отправлено с iPhone

Oct 7, 2010, в 21:03, Peter Wortmann <scpmw at leeds.ac.uk> написал(а):

> 
> On Tue, 2010-10-05 at 17:10 -0700, Evan Laforge wrote:
>> +1 for something to solve the "dummy <- m; case dummy of" problem.
>> Here are the possibilities I can think of:
> 
> Might be off-topic here, but I have wondered for a while why Haskell
> doesn't support something like follows:
> 
>  do case (<- m) of ...

I think it'd be better to write just 'case (<- m) of', without 'do'.

> 
> With the more general rule being:
> 
>  do ... e (<- m) g
>    =>
>  ... m >>= \tmp -> e tmp g
> 
> Reasons:
> * "<-" is already "sugary", and the transformation is similar. Just
>  removes the need for the user to define a throw-away name.
> * Better than liftMX and the Applicative operators. As shown, this is
>  more flexible while requiring less magic operators as a bonus. Also
>  makes more clear where the sides effects actually are.
> * Goes well with the spirit of getting the good parts of imperative
>  coding where it potentially makes the code more concise. Can be
>  abused, obviously, but I have also seen a lot of code that I feel   
>  could be written better using this.
> 
> Anything I am overlooking here? I tried to find a discussion about
> something like this, but didn't really know what to look for...
> 
> Greetings,
>  Peter Wortmann
> 
> 
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe


More information about the Haskell-Cafe mailing list