module Unison.Merge.ThreeWay ( ThreeWay (..), forgetLca, ) where import Data.Semialign (Semialign (alignWith), Unzip (unzipWith), Zip (zipWith)) import Data.These (These (..)) import Unison.Merge.TwoWay (TwoWay (..)) import Unison.Prelude data ThreeWay a = ThreeWay { forall a. ThreeWay a -> a lca :: !a, forall a. ThreeWay a -> a alice :: !a, forall a. ThreeWay a -> a bob :: !a } deriving stock ((forall m. Monoid m => ThreeWay m -> m) -> (forall m a. Monoid m => (a -> m) -> ThreeWay a -> m) -> (forall m a. Monoid m => (a -> m) -> ThreeWay a -> m) -> (forall a b. (a -> b -> b) -> b -> ThreeWay a -> b) -> (forall a b. (a -> b -> b) -> b -> ThreeWay a -> b) -> (forall b a. (b -> a -> b) -> b -> ThreeWay a -> b) -> (forall b a. (b -> a -> b) -> b -> ThreeWay a -> b) -> (forall a. (a -> a -> a) -> ThreeWay a -> a) -> (forall a. (a -> a -> a) -> ThreeWay a -> a) -> (forall a. ThreeWay a -> [a]) -> (forall a. ThreeWay a -> Bool) -> (forall a. ThreeWay a -> Int) -> (forall a. Eq a => a -> ThreeWay a -> Bool) -> (forall a. Ord a => ThreeWay a -> a) -> (forall a. Ord a => ThreeWay a -> a) -> (forall a. Num a => ThreeWay a -> a) -> (forall a. Num a => ThreeWay a -> a) -> Foldable ThreeWay forall a. Eq a => a -> ThreeWay a -> Bool forall a. Num a => ThreeWay a -> a forall a. Ord a => ThreeWay a -> a forall m. Monoid m => ThreeWay m -> m forall a. ThreeWay a -> Bool forall a. ThreeWay a -> Int forall a. ThreeWay a -> [a] forall a. (a -> a -> a) -> ThreeWay a -> a forall m a. Monoid m => (a -> m) -> ThreeWay a -> m forall b a. (b -> a -> b) -> b -> ThreeWay a -> b forall a b. (a -> b -> b) -> b -> ThreeWay a -> b forall (t :: * -> *). (forall m. Monoid m => t m -> m) -> (forall m a. Monoid m => (a -> m) -> t a -> m) -> (forall m a. Monoid m => (a -> m) -> t a -> m) -> (forall a b. (a -> b -> b) -> b -> t a -> b) -> (forall a b. (a -> b -> b) -> b -> t a -> b) -> (forall b a. (b -> a -> b) -> b -> t a -> b) -> (forall b a. (b -> a -> b) -> b -> t a -> b) -> (forall a. (a -> a -> a) -> t a -> a) -> (forall a. (a -> a -> a) -> t a -> a) -> (forall a. t a -> [a]) -> (forall a. t a -> Bool) -> (forall a. t a -> Int) -> (forall a. Eq a => a -> t a -> Bool) -> (forall a. Ord a => t a -> a) -> (forall a. Ord a => t a -> a) -> (forall a. Num a => t a -> a) -> (forall a. Num a => t a -> a) -> Foldable t $cfold :: forall m. Monoid m => ThreeWay m -> m fold :: forall m. Monoid m => ThreeWay m -> m $cfoldMap :: forall m a. Monoid m => (a -> m) -> ThreeWay a -> m foldMap :: forall m a. Monoid m => (a -> m) -> ThreeWay a -> m $cfoldMap' :: forall m a. Monoid m => (a -> m) -> ThreeWay a -> m foldMap' :: forall m a. Monoid m => (a -> m) -> ThreeWay a -> m $cfoldr :: forall a b. (a -> b -> b) -> b -> ThreeWay a -> b foldr :: forall a b. (a -> b -> b) -> b -> ThreeWay a -> b $cfoldr' :: forall a b. (a -> b -> b) -> b -> ThreeWay a -> b foldr' :: forall a b. (a -> b -> b) -> b -> ThreeWay a -> b $cfoldl :: forall b a. (b -> a -> b) -> b -> ThreeWay a -> b foldl :: forall b a. (b -> a -> b) -> b -> ThreeWay a -> b $cfoldl' :: forall b a. (b -> a -> b) -> b -> ThreeWay a -> b foldl' :: forall b a. (b -> a -> b) -> b -> ThreeWay a -> b $cfoldr1 :: forall a. (a -> a -> a) -> ThreeWay a -> a foldr1 :: forall a. (a -> a -> a) -> ThreeWay a -> a $cfoldl1 :: forall a. (a -> a -> a) -> ThreeWay a -> a foldl1 :: forall a. (a -> a -> a) -> ThreeWay a -> a $ctoList :: forall a. ThreeWay a -> [a] toList :: forall a. ThreeWay a -> [a] $cnull :: forall a. ThreeWay a -> Bool null :: forall a. ThreeWay a -> Bool $clength :: forall a. ThreeWay a -> Int length :: forall a. ThreeWay a -> Int $celem :: forall a. Eq a => a -> ThreeWay a -> Bool elem :: forall a. Eq a => a -> ThreeWay a -> Bool $cmaximum :: forall a. Ord a => ThreeWay a -> a maximum :: forall a. Ord a => ThreeWay a -> a $cminimum :: forall a. Ord a => ThreeWay a -> a minimum :: forall a. Ord a => ThreeWay a -> a $csum :: forall a. Num a => ThreeWay a -> a sum :: forall a. Num a => ThreeWay a -> a $cproduct :: forall a. Num a => ThreeWay a -> a product :: forall a. Num a => ThreeWay a -> a Foldable, (forall a b. (a -> b) -> ThreeWay a -> ThreeWay b) -> (forall a b. a -> ThreeWay b -> ThreeWay a) -> Functor ThreeWay forall a b. a -> ThreeWay b -> ThreeWay a forall a b. (a -> b) -> ThreeWay a -> ThreeWay 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) -> ThreeWay a -> ThreeWay b fmap :: forall a b. (a -> b) -> ThreeWay a -> ThreeWay b $c<$ :: forall a b. a -> ThreeWay b -> ThreeWay a <$ :: forall a b. a -> ThreeWay b -> ThreeWay a Functor, (forall x. ThreeWay a -> Rep (ThreeWay a) x) -> (forall x. Rep (ThreeWay a) x -> ThreeWay a) -> Generic (ThreeWay a) forall x. Rep (ThreeWay a) x -> ThreeWay a forall x. ThreeWay a -> Rep (ThreeWay a) x forall a. (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a forall a x. Rep (ThreeWay a) x -> ThreeWay a forall a x. ThreeWay a -> Rep (ThreeWay a) x $cfrom :: forall a x. ThreeWay a -> Rep (ThreeWay a) x from :: forall x. ThreeWay a -> Rep (ThreeWay a) x $cto :: forall a x. Rep (ThreeWay a) x -> ThreeWay a to :: forall x. Rep (ThreeWay a) x -> ThreeWay a Generic, Functor ThreeWay Foldable ThreeWay (Functor ThreeWay, Foldable ThreeWay) => (forall (f :: * -> *) a b. Applicative f => (a -> f b) -> ThreeWay a -> f (ThreeWay b)) -> (forall (f :: * -> *) a. Applicative f => ThreeWay (f a) -> f (ThreeWay a)) -> (forall (m :: * -> *) a b. Monad m => (a -> m b) -> ThreeWay a -> m (ThreeWay b)) -> (forall (m :: * -> *) a. Monad m => ThreeWay (m a) -> m (ThreeWay a)) -> Traversable ThreeWay forall (t :: * -> *). (Functor t, Foldable t) => (forall (f :: * -> *) a b. Applicative f => (a -> f b) -> t a -> f (t b)) -> (forall (f :: * -> *) a. Applicative f => t (f a) -> f (t a)) -> (forall (m :: * -> *) a b. Monad m => (a -> m b) -> t a -> m (t b)) -> (forall (m :: * -> *) a. Monad m => t (m a) -> m (t a)) -> Traversable t forall (m :: * -> *) a. Monad m => ThreeWay (m a) -> m (ThreeWay a) forall (f :: * -> *) a. Applicative f => ThreeWay (f a) -> f (ThreeWay a) forall (m :: * -> *) a b. Monad m => (a -> m b) -> ThreeWay a -> m (ThreeWay b) forall (f :: * -> *) a b. Applicative f => (a -> f b) -> ThreeWay a -> f (ThreeWay b) $ctraverse :: forall (f :: * -> *) a b. Applicative f => (a -> f b) -> ThreeWay a -> f (ThreeWay b) traverse :: forall (f :: * -> *) a b. Applicative f => (a -> f b) -> ThreeWay a -> f (ThreeWay b) $csequenceA :: forall (f :: * -> *) a. Applicative f => ThreeWay (f a) -> f (ThreeWay a) sequenceA :: forall (f :: * -> *) a. Applicative f => ThreeWay (f a) -> f (ThreeWay a) $cmapM :: forall (m :: * -> *) a b. Monad m => (a -> m b) -> ThreeWay a -> m (ThreeWay b) mapM :: forall (m :: * -> *) a b. Monad m => (a -> m b) -> ThreeWay a -> m (ThreeWay b) $csequence :: forall (m :: * -> *) a. Monad m => ThreeWay (m a) -> m (ThreeWay a) sequence :: forall (m :: * -> *) a. Monad m => ThreeWay (m a) -> m (ThreeWay a) Traversable) instance Applicative ThreeWay where pure :: a -> ThreeWay a pure :: forall a. a -> ThreeWay a pure a x = a -> a -> a -> ThreeWay a forall a. a -> a -> a -> ThreeWay a ThreeWay a x a x a x (<*>) :: ThreeWay (a -> b) -> ThreeWay a -> ThreeWay b ThreeWay a -> b f a -> b g a -> b h <*> :: forall a b. ThreeWay (a -> b) -> ThreeWay a -> ThreeWay b <*> ThreeWay a x a y a z = b -> b -> b -> ThreeWay b forall a. a -> a -> a -> ThreeWay a ThreeWay (a -> b f a x) (a -> b g a y) (a -> b h a z) instance Semialign ThreeWay where alignWith :: (These a b -> c) -> ThreeWay a -> ThreeWay b -> ThreeWay c alignWith :: forall a b c. (These a b -> c) -> ThreeWay a -> ThreeWay b -> ThreeWay c alignWith These a b -> c f (ThreeWay a a a b a c) (ThreeWay b x b y b z) = c -> c -> c -> ThreeWay c forall a. a -> a -> a -> ThreeWay a ThreeWay (These a b -> c f (a -> b -> These a b forall a b. a -> b -> These a b These a a b x)) (These a b -> c f (a -> b -> These a b forall a b. a -> b -> These a b These a b b y)) (These a b -> c f (a -> b -> These a b forall a b. a -> b -> These a b These a c b z)) instance Unzip ThreeWay where unzipWith :: (c -> (a, b)) -> ThreeWay c -> (ThreeWay a, ThreeWay b) unzipWith :: forall c a b. (c -> (a, b)) -> ThreeWay c -> (ThreeWay a, ThreeWay b) unzipWith c -> (a, b) f (ThreeWay c a c b c c) = let (a i, b x) = c -> (a, b) f c a (a j, b y) = c -> (a, b) f c b (a k, b z) = c -> (a, b) f c c in (a -> a -> a -> ThreeWay a forall a. a -> a -> a -> ThreeWay a ThreeWay a i a j a k, b -> b -> b -> ThreeWay b forall a. a -> a -> a -> ThreeWay a ThreeWay b x b y b z) instance Zip ThreeWay where zipWith :: (a -> b -> c) -> ThreeWay a -> ThreeWay b -> ThreeWay c zipWith :: forall a b c. (a -> b -> c) -> ThreeWay a -> ThreeWay b -> ThreeWay c zipWith a -> b -> c f (ThreeWay a a a b a c) (ThreeWay b x b y b z) = c -> c -> c -> ThreeWay c forall a. a -> a -> a -> ThreeWay a ThreeWay (a -> b -> c f a a b x) (a -> b -> c f a b b y) (a -> b -> c f a c b z) forgetLca :: ThreeWay a -> TwoWay a forgetLca :: forall a. ThreeWay a -> TwoWay a forgetLca ThreeWay {a $sel:alice:ThreeWay :: forall a. ThreeWay a -> a alice :: a alice, a $sel:bob:ThreeWay :: forall a. ThreeWay a -> a bob :: a bob} = TwoWay {a alice :: a $sel:alice:TwoWay :: a alice, a bob :: a $sel:bob:TwoWay :: a bob}