On Fri, Aug 03, 2007 at 05:48:18PM -0700, Brandon Michael Moore wrote:
> General purpose brackets are overkill here. I would really like a simple
> monadic case. What's so bad about
> 
> caseM mexpr of
>   p1 -> branch1
>   p2 -> branch2
> 
> vvvv
> 
> (mexpr >>= \e -> case e of
>   p1 -> branch1
>   p2 -> branch2)
> 
> It's simple sugar for working with monadic code, much like do notation.
> (indeed, it seems to plug a gap - we have do for sequencing, liftM and
> so on for application, but no sugar for case discrimination)
> 
> It's a much simpler sort of thing than this fancy sugar for intermixing
> code in various monads people have been talking about (so far it seems
> assumed that one is just Identity...)

I think the CaseLambda proposal on the Haskell' wiki solves this one
nicely.

mexpr >>= case of
  p1 -> branch1
  p2 -> branch2

You still have to use >>=, but you don't have to name the scrutinee (and
names are expensive cognitively).

Stefan

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to