module Unison.Merge.Updated
( Updated,
GUpdated (..),
bimap,
bitraverse,
Unison.Merge.Updated.foldMap,
fromPair,
Unison.Merge.Updated.map,
sequenceDefns,
toPair,
Unison.Merge.Updated.traverse,
Unison.Merge.Updated.unzip,
unzipWith,
Unison.Merge.Updated.zipWith,
)
where
import Control.DeepSeq (NFData)
import Unison.Prelude hiding (bimap)
import Unison.Util.Defns (Defns (..))
type Updated a =
GUpdated a a
data GUpdated a b = Updated
{ forall a b. GUpdated a b -> a
old :: a,
forall a b. GUpdated a b -> b
new :: b
}
deriving stock ((forall x. GUpdated a b -> Rep (GUpdated a b) x)
-> (forall x. Rep (GUpdated a b) x -> GUpdated a b)
-> Generic (GUpdated a b)
forall x. Rep (GUpdated a b) x -> GUpdated a b
forall x. GUpdated a b -> Rep (GUpdated a b) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a b x. Rep (GUpdated a b) x -> GUpdated a b
forall a b x. GUpdated a b -> Rep (GUpdated a b) x
$cfrom :: forall a b x. GUpdated a b -> Rep (GUpdated a b) x
from :: forall x. GUpdated a b -> Rep (GUpdated a b) x
$cto :: forall a b x. Rep (GUpdated a b) x -> GUpdated a b
to :: forall x. Rep (GUpdated a b) x -> GUpdated a b
Generic, Int -> GUpdated a b -> ShowS
[GUpdated a b] -> ShowS
GUpdated a b -> String
(Int -> GUpdated a b -> ShowS)
-> (GUpdated a b -> String)
-> ([GUpdated a b] -> ShowS)
-> Show (GUpdated a b)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall a b. (Show a, Show b) => Int -> GUpdated a b -> ShowS
forall a b. (Show a, Show b) => [GUpdated a b] -> ShowS
forall a b. (Show a, Show b) => GUpdated a b -> String
$cshowsPrec :: forall a b. (Show a, Show b) => Int -> GUpdated a b -> ShowS
showsPrec :: Int -> GUpdated a b -> ShowS
$cshow :: forall a b. (Show a, Show b) => GUpdated a b -> String
show :: GUpdated a b -> String
$cshowList :: forall a b. (Show a, Show b) => [GUpdated a b] -> ShowS
showList :: [GUpdated a b] -> ShowS
Show)
deriving anyclass (GUpdated a b -> ()
(GUpdated a b -> ()) -> NFData (GUpdated a b)
forall a. (a -> ()) -> NFData a
forall a b. (NFData a, NFData b) => GUpdated a b -> ()
$crnf :: forall a b. (NFData a, NFData b) => GUpdated a b -> ()
rnf :: GUpdated a b -> ()
NFData)
bimap :: (a -> b) -> (c -> d) -> GUpdated a c -> GUpdated b d
bimap :: forall a b c d.
(a -> b) -> (c -> d) -> GUpdated a c -> GUpdated b d
bimap a -> b
f c -> d
g (Updated a
x c
y) =
b -> d -> GUpdated b d
forall a b. a -> b -> GUpdated a b
Updated (a -> b
f a
x) (c -> d
g c
y)
bitraverse :: (Applicative f) => (a -> f b) -> (c -> f d) -> GUpdated a c -> f (GUpdated b d)
bitraverse :: forall (f :: * -> *) a b c d.
Applicative f =>
(a -> f b) -> (c -> f d) -> GUpdated a c -> f (GUpdated b d)
bitraverse a -> f b
f c -> f d
g (Updated a
x c
y) =
b -> d -> GUpdated b d
forall a b. a -> b -> GUpdated a b
Updated (b -> d -> GUpdated b d) -> f b -> f (d -> GUpdated b d)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> a -> f b
f a
x f (d -> GUpdated b d) -> f d -> f (GUpdated b d)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> c -> f d
g c
y
foldMap :: (Semigroup m) => (a -> m) -> Updated a -> m
foldMap :: forall m a. Semigroup m => (a -> m) -> Updated a -> m
foldMap a -> m
f (Updated a
x a
y) =
a -> m
f a
x m -> m -> m
forall a. Semigroup a => a -> a -> a
<> a -> m
f a
y
fromPair :: (a, b) -> GUpdated a b
fromPair :: forall a b. (a, b) -> GUpdated a b
fromPair (a
x, b
y) =
a -> b -> GUpdated a b
forall a b. a -> b -> GUpdated a b
Updated a
x b
y
map :: (a -> b) -> Updated a -> Updated b
map :: forall a b. (a -> b) -> Updated a -> Updated b
map a -> b
f =
(a -> b) -> (a -> b) -> GUpdated a a -> GUpdated b b
forall a b c d.
(a -> b) -> (c -> d) -> GUpdated a c -> GUpdated b d
bimap a -> b
f a -> b
f
sequenceDefns :: Updated (Defns terms types) -> Defns (Updated terms) (Updated types)
sequenceDefns :: forall terms types.
Updated (Defns terms types)
-> Defns (Updated terms) (Updated types)
sequenceDefns (Updated (Defns terms
oldTerms types
oldTypes) (Defns terms
newTerms types
newTypes)) =
Updated terms
-> Updated types -> Defns (Updated terms) (Updated types)
forall terms types. terms -> types -> Defns terms types
Defns (terms -> terms -> Updated terms
forall a b. a -> b -> GUpdated a b
Updated terms
oldTerms terms
newTerms) (types -> types -> Updated types
forall a b. a -> b -> GUpdated a b
Updated types
oldTypes types
newTypes)
toPair :: GUpdated a b -> (a, b)
toPair :: forall a b. GUpdated a b -> (a, b)
toPair (Updated a
x b
y) =
(a
x, b
y)
traverse :: (Applicative f) => (a -> f b) -> Updated a -> f (Updated b)
traverse :: forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Updated a -> f (Updated b)
traverse a -> f b
f =
(a -> f b) -> (a -> f b) -> GUpdated a a -> f (GUpdated b b)
forall (f :: * -> *) a b c d.
Applicative f =>
(a -> f b) -> (c -> f d) -> GUpdated a c -> f (GUpdated b d)
bitraverse a -> f b
f a -> f b
f
unzip :: GUpdated (a, b) (c, d) -> (GUpdated a c, GUpdated b d)
unzip :: forall a b c d.
GUpdated (a, b) (c, d) -> (GUpdated a c, GUpdated b d)
unzip (Updated (a
a, b
b) (c
c, d
d)) =
(a -> c -> GUpdated a c
forall a b. a -> b -> GUpdated a b
Updated a
a c
c, b -> d -> GUpdated b d
forall a b. a -> b -> GUpdated a b
Updated b
b d
d)
unzipWith :: (a -> (b, c)) -> Updated a -> (Updated b, Updated c)
unzipWith :: forall a b c. (a -> (b, c)) -> Updated a -> (Updated b, Updated c)
unzipWith a -> (b, c)
f (Updated a
x a
y) =
let (b
x1, c
x2) = a -> (b, c)
f a
x
(b
y1, c
y2) = a -> (b, c)
f a
y
in (b -> b -> GUpdated b b
forall a b. a -> b -> GUpdated a b
Updated b
x1 b
y1, c -> c -> GUpdated c c
forall a b. a -> b -> GUpdated a b
Updated c
x2 c
y2)
zipWith :: (a -> b -> c) -> Updated a -> Updated b -> Updated c
zipWith :: forall a b c. (a -> b -> c) -> Updated a -> Updated b -> Updated c
zipWith a -> b -> c
f (Updated a
a a
b) (Updated b
c b
d) =
c -> c -> GUpdated c c
forall a b. a -> b -> GUpdated a b
Updated (a -> b -> c
f a
a b
c) (a -> b -> c
f a
b b
d)