Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
This module provides a lossless way to do
diffing between two Map
s, and ways to
manipulate the diffs.
- data DeltaUnit a = DeltaUnit {}
- data Delta a
- data M
- diff :: (Eq a, Ord k) => Map k a -> Map k a -> Map k (Delta a)
- getSame :: Eq a => Delta a -> Maybe a
- getOld :: Delta a -> Maybe a
- getNew :: Delta a -> Maybe a
- getDelta :: Delta a -> Maybe (DeltaUnit a)
- getOriginal :: M -> Delta a -> Maybe a
- isSame :: Eq a => Delta a -> Bool
- isOld :: Delta a -> Bool
- isNew :: Delta a -> Bool
- isDelta :: Delta a -> Bool
- toSame :: Eq a => Map k (Delta a) -> Map k a
- toOld :: Map k (Delta a) -> Map k a
- toNew :: Map k (Delta a) -> Map k a
- toDelta :: Map k (Delta a) -> Map k (DeltaUnit a)
- toOriginal :: M -> Map k (Delta a) -> Map k a
- mapSame :: Eq a => (a -> b) -> Map k (Delta a) -> Map k b
- mapOld :: (a -> b) -> Map k (Delta a) -> Map k b
- mapNew :: (a -> b) -> Map k (Delta a) -> Map k b
- mapSame' :: Eq a => (a -> a) -> Map k (Delta a) -> Map k (Delta a)
- mapOld' :: forall k a. (a -> a) -> Map k (Delta a) -> Map k (Delta a)
- mapNew' :: forall k a. (a -> a) -> Map k (Delta a) -> Map k (Delta a)
Types
Encodes a diff between two as
.
Functor DeltaUnit Source # | |
Foldable DeltaUnit Source # | |
Traversable DeltaUnit Source # | |
Eq a => Eq (DeltaUnit a) Source # | |
Ord a => Ord (DeltaUnit a) Source # | |
Show a => Show (DeltaUnit a) Source # | |
Generic (DeltaUnit a) Source # | |
Generic1 * DeltaUnit Source # | |
type Rep (DeltaUnit a) Source # | |
type Rep1 * DeltaUnit Source # | |
The result of a diff of an entry within two Map
s.
In two Map
s 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
).
Diffing
Case analysis on Delta
Construction of special maps from a diff
toDelta :: Map k (Delta a) -> Map k (DeltaUnit a) Source #
Retrieve only the DeltaUnit
values out of the diff map.
Mapping
mapSame' :: Eq a => (a -> a) -> Map k (Delta a) -> Map k (Delta a) Source #
Map over all the Same
values, preserving the
remaining values in the map.