Alternative instance for Either
Nathan van Doorn
nvd1234 at gmail.com
Thu Jun 14 10:37:24 UTC 2018
Proposal: add:
instance Monoid e => Alternative (Either e) where
empty = Left mempty
Left a <|> Left b = Left (a `mappend` b)
Right a <|> _ = Right a
_ <|> Right b = Right b
instance Monoid e => MonadPlus (Either e) where
...
to base.
This is a reasonably obvious instance which I am pretty sure is law abiding.
It'd be useful for defining a series of computations which may fail, where
we only care about one success.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20180614/ea6a5eb7/attachment.html>
More information about the Libraries
mailing list