On Tue, Sep 15, 2009 at 6:21 AM, Brandon S. Allbery KF8NH <allbery@ece.cmu.edu> wrote:
On Sep 14, 2009, at 14:42 , Michael Snoyman wrote:
I understand that fail being in Monad is controversial, but my version of the function works in *all* monads. This is very 

Not really; "fail" in non-MonadPlus-es is a rather poorly defined notion, and there are no guarantees that the result will be at all sane.  "mzero" is well defined.

mzero also does not allow giving error messages. There are times when you want to be able to fail with an explanation of why. fail seems to fit the bill properly for this (fail taking a String argument and all...).

Now you point out that fail is not always properly defined. I quite agree with that. Nonetheless, in the simple cases I am trying to address here, it is IMO the best option available. If you end up using the function only with monads that properly define fail, then all the better.

Michael