@@ -6,7 +6,7 @@ import Control.Extend (class Extend)
66import Data.Bifunctor (class Bifunctor )
77import Data.Bitraversable (class Bitraversable , class Bifoldable , bitraverse )
88import Data.Functor.Invariant (class Invariant , imapF )
9- import Data.Maybe (Maybe (..))
9+ import Data.Maybe (Maybe (..), isJust )
1010import Data.Traversable (class Traversable , class Foldable , foldMap , foldl , foldr )
1111import Data.Tuple (Tuple (..))
1212
@@ -147,3 +147,22 @@ that :: forall a b. These a b -> Maybe b
147147that = case _ of
148148 That x -> Just x
149149 _ -> Nothing
150+
151+ -- | Returns the `a` and `b` values if and only if they are constructed
152+ -- | with `Both`.
153+ both :: forall a b . These a b -> Maybe (Tuple a b )
154+ both = case _ of
155+ Both a x -> Just (Tuple a x)
156+ _ -> Nothing
157+
158+ -- | Returns `true` when the `These` value is `This`
159+ isThis :: forall a b . These a b -> Boolean
160+ isThis = isJust <<< this
161+
162+ -- | Returns `true` when the `These` value is `That`
163+ isThat :: forall a b . These a b -> Boolean
164+ isThat = isJust <<< that
165+
166+ -- | Returns `true` when the `These` value is `Both`
167+ isBoth :: forall a b . These a b -> Boolean
168+ isBoth = isJust <<< both
0 commit comments