Add default MonadPlus or Alternative method to MonadFail
Baldur Blöndal
baldurpet at gmail.com
Thu Nov 17 22:45:36 UTC 2016
The documentation for Control.Monad.Fail notes
> If your Monad is also MonadPlus, a popular definition is
>> fail _ = mzero
This could be made a default definition for MonadPlus or Alternative
> class Monad m => MonadFail m where
> fail :: String -> m a
> fail = const empty
> default fail :: Alternative m => String -> m a
This simplifies instances like [] and Maybe
> instance MonadFail []
> instance MonadFail Maybe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20161117/a3c65b4b/attachment.html>
More information about the Libraries
mailing list