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

Peter Wortmann scpmw at leeds.ac.uk
Thu Oct 7 13:03:48 EDT 2010

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 ...

With the more general rule being:

  do ... e (<- m) g
  ... m >>= \tmp -> e tmp g

* "<-" 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...

  Peter Wortmann

More information about the Haskell-Cafe mailing list