mirror of
https://github.com/github/semantic.git
synced 2024-12-23 06:41:45 +03:00
Generalize coalesceBy
to Both (Coalesce a)
.
This commit is contained in:
parent
767a9e93fc
commit
6dfb8524ff
@ -55,10 +55,10 @@ instance Monoid a => Monoid (Both a) where
|
||||
mappend a b = mappend <$> a <*> b
|
||||
|
||||
instance (PartialSemigroup a, Monoid a) => PartialSemigroup (Both a) where
|
||||
coalesce = coalesceBy coalesce
|
||||
coalesce = coalesceBy (pure coalesce)
|
||||
|
||||
coalesceBy :: Monoid a => Coalesce a -> Both a -> Both a -> Maybe (Both a)
|
||||
coalesceBy coalesce a b = case coalesce <$> a <*> b of
|
||||
coalesceBy :: Monoid a => Both (Coalesce a) -> Both a -> Both a -> Maybe (Both a)
|
||||
coalesceBy coalesce a b = case coalesce <*> a <*> b of
|
||||
Both (Just l, Just r) -> Just (both l r)
|
||||
Both (Nothing, Just r) -> Just (both (fst a `mappend` fst b) r)
|
||||
Both (Just l, Nothing) -> Just (both l (snd a `mappend` snd b))
|
||||
|
Loading…
Reference in New Issue
Block a user