[Haskell] A collection of related proposals regarding monads

ajb at spamcop.net ajb at spamcop.net
Wed Jan 4 18:19:15 EST 2006

G'day all.

I wrote:

> > My feeling is that do { p <- xs; return e } should behave identically
> > (modulo the precise error message if the pattern match fails) to
> > map (\p -> e) xs.  Your proposal would make it into a map/filter
> > hybrid.

Which, of course, it is now.  I blame lack of caffeine.

Quoting Cale Gibbard <cgibbard at gmail.com>:

> Okay, so how about we separate these?
> do {p <- e; stmts} = e >>= \p -> do {stmts}
> do {p <-: e; stmts} = let ok p = do {stmts}; ok _ = mzero in e >>= ok
> (note the new symbol for monadically failing pattern match)

Not happy.  If anything, it should be the former which gets the new
symbol, to make it the same as list comprehensions.  But this would
break backwards compatibility.

Andrew Bromage

More information about the Haskell mailing list