module Unison.Merge.EitherWayI
( EitherWayI (..),
includingAlice,
excludingAlice,
value,
)
where
data EitherWayI a
= OnlyAlice a
| OnlyBob a
| AliceAndBob a
deriving stock ((forall a b. (a -> b) -> EitherWayI a -> EitherWayI b)
-> (forall a b. a -> EitherWayI b -> EitherWayI a)
-> Functor EitherWayI
forall a b. a -> EitherWayI b -> EitherWayI a
forall a b. (a -> b) -> EitherWayI a -> EitherWayI b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> EitherWayI a -> EitherWayI b
fmap :: forall a b. (a -> b) -> EitherWayI a -> EitherWayI b
$c<$ :: forall a b. a -> EitherWayI b -> EitherWayI a
<$ :: forall a b. a -> EitherWayI b -> EitherWayI a
Functor, Int -> EitherWayI a -> ShowS
[EitherWayI a] -> ShowS
EitherWayI a -> String
(Int -> EitherWayI a -> ShowS)
-> (EitherWayI a -> String)
-> ([EitherWayI a] -> ShowS)
-> Show (EitherWayI a)
forall a. Show a => Int -> EitherWayI a -> ShowS
forall a. Show a => [EitherWayI a] -> ShowS
forall a. Show a => EitherWayI a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> EitherWayI a -> ShowS
showsPrec :: Int -> EitherWayI a -> ShowS
$cshow :: forall a. Show a => EitherWayI a -> String
show :: EitherWayI a -> String
$cshowList :: forall a. Show a => [EitherWayI a] -> ShowS
showList :: [EitherWayI a] -> ShowS
Show)
includingAlice :: EitherWayI a -> Maybe a
includingAlice :: forall a. EitherWayI a -> Maybe a
includingAlice = \case
OnlyAlice a
x -> a -> Maybe a
forall a. a -> Maybe a
Just a
x
AliceAndBob a
x -> a -> Maybe a
forall a. a -> Maybe a
Just a
x
OnlyBob a
_ -> Maybe a
forall a. Maybe a
Nothing
excludingAlice :: EitherWayI a -> Maybe a
excludingAlice :: forall a. EitherWayI a -> Maybe a
excludingAlice = \case
OnlyBob a
x -> a -> Maybe a
forall a. a -> Maybe a
Just a
x
OnlyAlice a
_ -> Maybe a
forall a. Maybe a
Nothing
AliceAndBob a
_ -> Maybe a
forall a. Maybe a
Nothing
value :: EitherWayI a -> a
value :: forall a. EitherWayI a -> a
value = \case
OnlyAlice a
x -> a
x
OnlyBob a
x -> a
x
AliceAndBob a
x -> a
x