diff --git a/witherable/src/Witherable.hs b/witherable/src/Witherable.hs index 964a854..d6ee553 100644 --- a/witherable/src/Witherable.hs +++ b/witherable/src/Witherable.hs @@ -190,6 +190,7 @@ instance Witherable Maybe where instance Filterable Option where mapMaybe f = (>>= Option . f) + drain _ = Option Nothing {-# INLINE mapMaybe #-} instance Witherable Option where @@ -207,6 +208,9 @@ instance Monoid e => Filterable (Either e) where mapMaybe f (Right a) = maybe (Left mempty) Right $ f a {-# INLINABLE mapMaybe #-} + drain (Left e) = Left e + drain (Right _) = Left mempty + instance Monoid e => Witherable (Either e) where wither _ (Left e) = pure (Left e) wither f (Right a) = fmap (maybe (Left mempty) Right) (f a)