Hi folks

Wolfgang Jeltsch wrote:

Am Mittwoch, 4. Januar 2006 21:54 schrieb Cale Gibbard:
I personally feel that the inclusion of 'fail' in the Monad class is
an ugly solution to the problem of pattern matching, and gives the
incorrect impression that monads should have some builtin notion of
failure.

I totally agree!

I agree that 'fail' is a bit of a hack, but it has some sort of rationale to it. Have you forgotten that Haskell has a builtin notion of failure? If you choose to, you can see the 'fail' method simply as a way to deprecate this notion (in which well typed programs go with a bang) for a whimper-like notion of failure provided by the monad. The way it's used is consistent with that view: 'fail' gets called in situations which would make a pure [cough] computation bomb. I'm fairly grateful for it, to be honest.

One thing which might help, if it were possible, is to allow subclasses to provide default implementations for the methods of superclasses. And then MonadZero (of which I'm broadly in favour, caveats another time) can provide a default implementation of fail. Also Monad can provide a default implementation of Applicative's methods; Applicative can provide a default implementation of fmap, etc.

Whilst failure remains one of the basic freedoms, I think we should be ready to live with it.

But yes, it is worth opening this can of worms again, I believe...

All the best

Conor
_______________________________________________
Haskell mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to