[Haskell-cafe] case of (was: [Haskell] Mixing monadic and non-monadic functions)

Henning Thielemann lemming at henning-thielemann.de
Tue Sep 20 04:02:56 EDT 2005

On Mon, 19 Sep 2005, Andrew Pimlott wrote:

> On Sat, Sep 17, 2005 at 06:56:36PM +0100, Ben Rudiak-Gould wrote:
> >   * The new syntax is really nice as a replacement for the annoyingly
> >     common "x <- foo ; case x of..." idiom that I've always disliked.
> I might wish for "case of" to mean "\x -> case x of":
>     foo >>= case of ...

You mean that 'case' should be a function with the selecting value as last
argument? So e.g.

  (case of {Nothing -> g; (Just x) -> f x; })

would be equivalent to

  (maybe g f)

> Useful outside of monads, eg to write anonymous functions for map.

Yes, this would be nice. This notation could even replace the current one
to prevent from mistakes by mixing up both notations.

More information about the Haskell-Cafe mailing list