1
1
mirror of https://github.com/github/semantic.git synced 2025-01-03 13:02:37 +03:00

Add a Bitraversable instance over These.

This commit is contained in:
Rob Rix 2016-04-13 16:15:42 -04:00
parent 0867ae807f
commit 156c8820e6

View File

@ -2,6 +2,7 @@ module Data.Bifunctor.These where
import Data.Bifunctor import Data.Bifunctor
import Data.Bifoldable import Data.Bifoldable
import Data.Bitraversable
data These a b = This a | That b | These a b data These a b = This a | That b | These a b
deriving (Eq, Show) deriving (Eq, Show)
@ -32,3 +33,8 @@ instance Bifunctor These where
instance Bifoldable These where instance Bifoldable These where
bifoldMap f g = these f g ((. g) . mappend . f) bifoldMap f g = these f g ((. g) . mappend . f)
instance Bitraversable These where
bitraverse f _ (This a) = This <$> f a
bitraverse _ g (That b) = That <$> g b
bitraverse f g (These a b) = These <$> f a <*> g b