[Haskell-cafe] IO (Either a Error) question

Ross Paterson ross at soi.city.ac.uk
Fri May 7 20:15:11 EDT 2010


On Sat, May 08, 2010 at 01:54:21AM +0200, Limestraël wrote:
> > Personally I think fail is a terrible wart, and should be shunned.
> 
> So do I.
> I can't understand its purpose since monads which can fail can be implemented
> through MonadPlus.

It was introduced to implement pattern match failure in do-notation,
in Section 3.14 of the Haskell Report:

  do {p <- e; stmts} = let ok p = do {stmts}
                           ok _ = fail "..."
                       in e >>= ok


More information about the Haskell-Cafe mailing list