Removing MonadFail from Monad

Tom Ellis tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk
Tue Dec 17 13:09:27 UTC 2013


On Mon, Dec 16, 2013 at 04:47:42PM -0800, John Lato wrote:
> On Mon, Dec 16, 2013 at 2:54 PM, Tom Ellis <
> tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk> wrote:
> 
> > On Mon, Dec 16, 2013 at 11:26:39PM +0100, David Luposchainsky wrote:
> > > I feel like there are a couple of elephants in the room that are sort of
> > > important but nobody really addresses them directly. One of them was
> > > what became the AMP, and `fail` is another one.
> >
> > Is it written up somewhere why pattern match failure in 'do' is a 'fail'
> > but
> > pattern match failure elsewhere is just pattern match failure?
> >
> > Malcolm Wallace mentioned that it convenient when writing parsers, and his
> > example is indeed neat, but is has someone done a more substantial
> > investigation the benefits of this special case?
> 
> AFAIK, it was done this way for list comprehensions.  Currently, you can
> write e.g.
> 
> > rights = [x | Right x <- listOfEithers]
> 
> and it works properly.
[...]

Sure, but that then just raises the question "why was this special case
added for list comprehensions"?

To put it another way, if the original implementation of comprehensions and
do had treated pattern match failure just as pattern match failure, would a
proposal to switch to a 'fail' semantics stand a chance of being accepted? 
I'm not so sure.  Admittedly it allows for some neat code, but it really is
a very special case.

Tom


More information about the Libraries mailing list