-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | diff on maps
--
-- a very general way of lossless diffing on maps
@package diffmap
@version 0.1.0.0
-- | This module provides a lossless way to do diffing between two
-- Maps, and ways to manipulate the diffs.
module Data.Map.Delta
-- | Encodes a diff between two as.
data DeltaUnit a
DeltaUnit :: !a -> !a -> DeltaUnit a
[old] :: DeltaUnit a -> !a
[new] :: DeltaUnit a -> !a
-- | The result of a diff of an entry within two Maps.
--
-- In two Maps m1 and m2, when performing a diff, this type
-- encodes the following situations:
--
-- Same key, different values: Stores the two values in the Delta
-- constructor.
--
-- Same key, same values: Stores the value in the Same constructor.
--
-- Key exists in m1 but not m2: Stores the value in the Old constructor.
--
-- Key exists in m2 but not m1: Stores the value in the New constructor.
--
-- This behaviour ensures that we don't lose any information, meaning we
-- can reconstruct either of the original Map k
-- a from a Map k (Delta a).
data Delta a
Delta :: !(DeltaUnit a) -> Delta a
Same :: !a -> Delta a
Old :: !a -> Delta a
New :: !a -> Delta a
-- | M1 = First Map, M2 = Second Map. Used as an argument for
-- functions that care about which Map to reconstruct.
data M
M1 :: M
M2 :: M
-- | Takes two Maps and returns a Map from the same key type
-- to Delta a, where Delta a encodes
-- differences between entries.
diff :: (Eq a, Ord k) => Map k a -> Map k a -> Map k (Delta a)
-- | Potentially get the Same value out of a Delta.
getSame :: Eq a => Delta a -> Maybe a
-- | Potentially get the Old value out of a Delta.
getOld :: Delta a -> Maybe a
-- | Potentially get the New value out of a Delta.
getNew :: Delta a -> Maybe a
-- | Potentially get the DeltaUnit value out of a Delta.
getDelta :: Delta a -> Maybe (DeltaUnit a)
-- | Potentially get the original value out of the Delta.
getOriginal :: M -> Delta a -> Maybe a
-- | Is the Delta an encoding of same values?
isSame :: Eq a => Delta a -> Bool
-- | Is the Delta an encoding of old values?
isOld :: Delta a -> Bool
-- | Is the Delta an encoding of new values?
isNew :: Delta a -> Bool
-- | Is the Delta an encoding of changed values?
isDelta :: Delta a -> Bool
-- | Retrieve the Same values out of the diff map.
toSame :: Eq a => Map k (Delta a) -> Map k a
-- | Retrieve only the Old values out of the diff map.
toOld :: Map k (Delta a) -> Map k a
-- | Retrieve only the New values out of the diff map.
toNew :: Map k (Delta a) -> Map k a
-- | Retrieve only the DeltaUnit values out of the diff map.
toDelta :: Map k (Delta a) -> Map k (DeltaUnit a)
-- | Construct either the old Map or new Map from a diff
toOriginal :: M -> Map k (Delta a) -> Map k a
-- | Map over all Same values, returning a map of just the
-- transformed values. This can be more efficient than calling
-- toSame and then Data.Map's map.
mapSame :: Eq a => (a -> b) -> Map k (Delta a) -> Map k b
-- | Map over all Old values, returning a map of just the
-- transformed values. This can be more efficient than calling
-- toOld and then Data.Map's map.
mapOld :: (a -> b) -> Map k (Delta a) -> Map k b
-- | Map over all New values, returning a map of just the
-- transformed values. This can be more efficient than calling
-- toNew and then Data.Map's map.
mapNew :: (a -> b) -> Map k (Delta a) -> Map k b
-- | Map over all the Same values, preserving the remaining values
-- in the map.
mapSame' :: Eq a => (a -> a) -> Map k (Delta a) -> Map k (Delta a)
-- | Map over all the Old values, preserving the remaining values in
-- the map.
mapOld' :: forall k a. (a -> a) -> Map k (Delta a) -> Map k (Delta a)
-- | Map over all the New values, preserving the remaining values in
-- the map.
mapNew' :: forall k a. (a -> a) -> Map k (Delta a) -> Map k (Delta a)
instance Data.Traversable.Traversable Data.Map.Delta.Delta
instance GHC.Show.Show a => GHC.Show.Show (Data.Map.Delta.Delta a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.Map.Delta.Delta a)
instance GHC.Generics.Generic1 Data.Map.Delta.Delta
instance GHC.Generics.Generic (Data.Map.Delta.Delta a)
instance GHC.Base.Functor Data.Map.Delta.Delta
instance Data.Foldable.Foldable Data.Map.Delta.Delta
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Map.Delta.Delta a)
instance Data.Traversable.Traversable Data.Map.Delta.DeltaUnit
instance GHC.Show.Show a => GHC.Show.Show (Data.Map.Delta.DeltaUnit a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Data.Map.Delta.DeltaUnit a)
instance GHC.Generics.Generic1 Data.Map.Delta.DeltaUnit
instance GHC.Generics.Generic (Data.Map.Delta.DeltaUnit a)
instance GHC.Base.Functor Data.Map.Delta.DeltaUnit
instance Data.Foldable.Foldable Data.Map.Delta.DeltaUnit
instance GHC.Classes.Eq a => GHC.Classes.Eq (Data.Map.Delta.DeltaUnit a)