
27 Nov
2014
27 Nov
'14
5:29 p.m.
Hi, Lately, I found myself wanting to use the following Monoid instance: ```` instance (Monoid b) => Monoid (Either a b) where mempty = Right mempty Left e `mappend` _ = Left e _ `mappend` Left e = Left e Right x `mappend` Right y = Right (x `mappend` y) ```` It would seem quite justified to me, given the left-bias of Either elsewhere in base. Is there any particular reason why it shouldn't be defined? It would break the instance for Either in `semigroups`, which is ```` instance Semigroup (Either a b) where Left _ <> b = b a <> _ = a ```` But I think mine is more useful, and has the additional advantage of having `mappend` to behave very similar to the `mappend` for `Maybe`. Francesco