patch-0.0.3.2: Data structures for describing changes to other data structures.

Data.Patch

Description

Synopsis

# Documentation

The elements of an Additive Semigroup can be considered as patches of their own type.

Constructors

Instances
 Additive p => Patch (AdditivePatch p) Source # Instance detailsDefined in Data.Patch Associated Typestype PatchTarget (AdditivePatch p) :: Type Source # Methods type PatchTarget (AdditivePatch p) Source # Instance detailsDefined in Data.Patch type PatchTarget (AdditivePatch p) = p

class Semigroup q => Additive q Source #

An Additive Semigroup is one where (<>) is commutative

Instances

class (Semigroup q, Monoid q) => Group q where Source #

A Group is a Monoid where every element has an inverse.

Minimal complete definition

negateG

Methods

negateG :: q -> q Source #

(~~) :: q -> q -> q Source #

Instances
 Group () Source # Trivial group. Instance detailsDefined in Data.Patch MethodsnegateG :: () -> () Source #(~~) :: () -> () -> () Source # Group a => Group (Identity a) Source # Ideitnty lifts groups pointwise (at only one point) Instance detailsDefined in Data.Patch Methods(~~) :: Identity a -> Identity a -> Identity a Source # Group b => Group (a -> b) Source # Functions lift groups pointwise. Instance detailsDefined in Data.Patch MethodsnegateG :: (a -> b) -> a -> b Source #(~~) :: (a -> b) -> (a -> b) -> a -> b Source # (Group a, Group b) => Group (a, b) Source # Product group. A Pair of groups gives rise to a group Instance detailsDefined in Data.Patch MethodsnegateG :: (a, b) -> (a, b) Source #(~~) :: (a, b) -> (a, b) -> (a, b) Source # Group (Proxy x) Source # Trivial group, Functor style Instance detailsDefined in Data.Patch MethodsnegateG :: Proxy x -> Proxy x Source #(~~) :: Proxy x -> Proxy x -> Proxy x Source # (Ord k, Group q) => Group (MonoidalMap k q) Source # Instance detailsDefined in Data.Patch MethodsnegateG :: MonoidalMap k q -> MonoidalMap k q Source #(~~) :: MonoidalMap k q -> MonoidalMap k q -> MonoidalMap k q Source # Group a => Group (Const a x) Source # Const lifts groups into a functor. Instance detailsDefined in Data.Patch MethodsnegateG :: Const a x -> Const a x Source #(~~) :: Const a x -> Const a x -> Const a x Source # (Group (f a), Group (g a)) => Group ((f :*: g) a) Source # Product of groups, Functor style. Instance detailsDefined in Data.Patch MethodsnegateG :: (f :*: g) a -> (f :*: g) a Source #(~~) :: (f :*: g) a -> (f :*: g) a -> (f :*: g) a Source # Group (f (g a)) => Group ((f :.: g) a) Source # Instance detailsDefined in Data.Patch MethodsnegateG :: (f :.: g) a -> (f :.: g) a Source #(~~) :: (f :.: g) a -> (f :.: g) a -> (f :.: g) a Source #

class Patch p where Source #

A Patch type represents a kind of change made to a datastructure.

If an instance of Patch is also an instance of Semigroup, it should obey the law that applyAlways (f <> g) == applyAlways f . applyAlways g.

Associated Types

type PatchTarget p :: * Source #

Methods

apply :: p -> PatchTarget p -> Maybe (PatchTarget p) Source #

Apply the patch p a to the value a. If no change is needed, return Nothing.

Instances
 Source # Identity can be used as a Patch that always fully replaces the value Instance detailsDefined in Data.Patch.Class Associated Typestype PatchTarget (Identity a) :: Type Source # Methodsapply :: Identity a -> PatchTarget (Identity a) -> Maybe (PatchTarget (Identity a)) Source # Source # Apply the insertions or deletions to a given IntMap. Instance detailsDefined in Data.Patch.IntMap Associated Typestype PatchTarget (PatchIntMap a) :: Type Source # Methods Additive p => Patch (AdditivePatch p) Source # Instance detailsDefined in Data.Patch Associated Typestype PatchTarget (AdditivePatch p) :: Type Source # Methods Patch (Proxy a) Source # Proxy can be used as a Patch that does nothing. Instance detailsDefined in Data.Patch.Class Associated Typestype PatchTarget (Proxy a) :: Type Source # Methodsapply :: Proxy a -> PatchTarget (Proxy a) -> Maybe (PatchTarget (Proxy a)) Source # Ord k => Patch (PatchMap k v) Source # Apply the insertions or deletions to a given Map. Instance detailsDefined in Data.Patch.Map Associated Typestype PatchTarget (PatchMap k v) :: Type Source # Methodsapply :: PatchMap k v -> PatchTarget (PatchMap k v) -> Maybe (PatchTarget (PatchMap k v)) Source # Ord k => Patch (PatchMapWithMove k v) Source # Apply the insertions, deletions, and moves to a given Map Instance detailsDefined in Data.Patch.MapWithMove Associated Typestype PatchTarget (PatchMapWithMove k v) :: Type Source # Methodsapply :: PatchMapWithMove k v -> PatchTarget (PatchMapWithMove k v) -> Maybe (PatchTarget (PatchMapWithMove k v)) Source # (Ord k, Patch p) => Patch (PatchMapWithPatchingMove k p) Source # Apply the insertions, deletions, and moves to a given Map Instance detailsDefined in Data.Patch.MapWithPatchingMove Associated Typestype PatchTarget (PatchMapWithPatchingMove k p) :: Type Source # Methods GCompare k2 => Patch (PatchDMap k2 v) Source # Apply the insertions or deletions to a given DMap. Instance detailsDefined in Data.Patch.DMap Associated Typestype PatchTarget (PatchDMap k2 v) :: Type Source # Methodsapply :: PatchDMap k2 v -> PatchTarget (PatchDMap k2 v) -> Maybe (PatchTarget (PatchDMap k2 v)) Source # GCompare k2 => Patch (PatchDMapWithMove k2 v) Source # Apply the insertions, deletions, and moves to a given DMap. Instance detailsDefined in Data.Patch.DMapWithMove Associated Typestype PatchTarget (PatchDMapWithMove k2 v) :: Type Source # Methodsapply :: PatchDMapWithMove k2 v -> PatchTarget (PatchDMapWithMove k2 v) -> Maybe (PatchTarget (PatchDMapWithMove k2 v)) Source #

applyAlways :: Patch p => p -> PatchTarget p -> PatchTarget p Source #

Apply a Patch; if it does nothing, return the original value

composePatchFunctions :: (Patch p, Semigroup p) => (PatchTarget p -> p) -> (PatchTarget p -> p) -> PatchTarget p -> p Source #

Like '(.)', but composes functions that return patches rather than functions that return new values. The Semigroup instance for patches must apply patches right-to-left, like '(.)'.

newtype PatchIntMap a Source #

Patch for IntMap which represents insertion or deletion of keys in the mapping. Internally represented by 'IntMap (Maybe a)', where Just means insert/update and Nothing means delete.

Constructors

 PatchIntMap FieldsunPatchIntMap :: IntMap (Maybe a)
Instances
 Source # Instance detailsDefined in Data.Patch.IntMap Methodsfmap :: (a -> b) -> PatchIntMap a -> PatchIntMap b #(<$) :: a -> PatchIntMap b -> PatchIntMap a # Source # Instance detailsDefined in Data.Patch.IntMap Methodsfold :: Monoid m => PatchIntMap m -> m #foldMap :: Monoid m => (a -> m) -> PatchIntMap a -> m #foldr :: (a -> b -> b) -> b -> PatchIntMap a -> b #foldr' :: (a -> b -> b) -> b -> PatchIntMap a -> b #foldl :: (b -> a -> b) -> b -> PatchIntMap a -> b #foldl' :: (b -> a -> b) -> b -> PatchIntMap a -> b #foldr1 :: (a -> a -> a) -> PatchIntMap a -> a #foldl1 :: (a -> a -> a) -> PatchIntMap a -> a #toList :: PatchIntMap a -> [a] #null :: PatchIntMap a -> Bool #length :: PatchIntMap a -> Int #elem :: Eq a => a -> PatchIntMap a -> Bool #maximum :: Ord a => PatchIntMap a -> a #minimum :: Ord a => PatchIntMap a -> a #sum :: Num a => PatchIntMap a -> a #product :: Num a => PatchIntMap a -> a # Source # Instance detailsDefined in Data.Patch.IntMap Methodstraverse :: Applicative f => (a -> f b) -> PatchIntMap a -> f (PatchIntMap b) #sequenceA :: Applicative f => PatchIntMap (f a) -> f (PatchIntMap a) #mapM :: Monad m => (a -> m b) -> PatchIntMap a -> m (PatchIntMap b) #sequence :: Monad m => PatchIntMap (m a) -> m (PatchIntMap a) # Source # Instance detailsDefined in Data.Patch.IntMap Methodsimap :: (Int -> a -> b) -> PatchIntMap a -> PatchIntMap b #imapped :: IndexedSetter Int (PatchIntMap a) (PatchIntMap b) a b # Source # Instance detailsDefined in Data.Patch.IntMap MethodsifoldMap :: Monoid m => (Int -> a -> m) -> PatchIntMap a -> m #ifoldr :: (Int -> a -> b -> b) -> b -> PatchIntMap a -> b #ifoldl :: (Int -> b -> a -> b) -> b -> PatchIntMap a -> b #ifoldr' :: (Int -> a -> b -> b) -> b -> PatchIntMap a -> b #ifoldl' :: (Int -> b -> a -> b) -> b -> PatchIntMap a -> b # Source # Instance detailsDefined in Data.Patch.IntMap Methodsitraverse :: Applicative f => (Int -> a -> f b) -> PatchIntMap a -> f (PatchIntMap b) #itraversed :: IndexedTraversal Int (PatchIntMap a) (PatchIntMap b) a b # Eq a => Eq (PatchIntMap a) Source # Instance detailsDefined in Data.Patch.IntMap Methods(==) :: PatchIntMap a -> PatchIntMap a -> Bool #(/=) :: PatchIntMap a -> PatchIntMap a -> Bool # Ord a => Ord (PatchIntMap a) Source # Instance detailsDefined in Data.Patch.IntMap Methodscompare :: PatchIntMap a -> PatchIntMap a -> Ordering #(<) :: PatchIntMap a -> PatchIntMap a -> Bool #(<=) :: PatchIntMap a -> PatchIntMap a -> Bool #(>) :: PatchIntMap a -> PatchIntMap a -> Bool #(>=) :: PatchIntMap a -> PatchIntMap a -> Bool #max :: PatchIntMap a -> PatchIntMap a -> PatchIntMap a #min :: PatchIntMap a -> PatchIntMap a -> PatchIntMap a # Read a => Read (PatchIntMap a) Source # Instance detailsDefined in Data.Patch.IntMap Methods Show a => Show (PatchIntMap a) Source # Instance detailsDefined in Data.Patch.IntMap MethodsshowsPrec :: Int -> PatchIntMap a -> ShowS #show :: PatchIntMap a -> String #showList :: [PatchIntMap a] -> ShowS # Source # a <> b will apply the changes of b and then apply the changes of a. If the same key is modified by both patches, the one on the left will take precedence. Instance detailsDefined in Data.Patch.IntMap Methods(<>) :: PatchIntMap v -> PatchIntMap v -> PatchIntMap v #stimes :: Integral b => b -> PatchIntMap v -> PatchIntMap v # Source # Instance detailsDefined in Data.Patch.IntMap Methodsmappend :: PatchIntMap a -> PatchIntMap a -> PatchIntMap a #mconcat :: [PatchIntMap a] -> PatchIntMap a # Source # Instance detailsDefined in Data.Patch.IntMap Associated Typestype Unwrapped (PatchIntMap a) :: Type # Methods Source # Instance detailsDefined in Data.Patch.IntMap Methods Source # Apply the insertions or deletions to a given IntMap. Instance detailsDefined in Data.Patch.IntMap Associated Typestype PatchTarget (PatchIntMap a) :: Type Source # Methods PatchIntMap a1 ~ t => Rewrapped (PatchIntMap a2) t Source # Instance detailsDefined in Data.Patch.IntMap type Unwrapped (PatchIntMap a) Source # Instance detailsDefined in Data.Patch.IntMap type Unwrapped (PatchIntMap a) = IntMap (Maybe a) type PatchTarget (PatchIntMap a) Source # Instance detailsDefined in Data.Patch.IntMap type PatchTarget (PatchIntMap a) = IntMap a mapIntMapPatchWithKey :: (Int -> a -> b) -> PatchIntMap a -> PatchIntMap b Source # Map a function Int -> a -> b over all as in the given PatchIntMap a (that is, all inserts/updates), producing a PatchIntMap b. traverseIntMapPatchWithKey :: Applicative f => (Int -> a -> f b) -> PatchIntMap a -> f (PatchIntMap b) Source # Map an effectful function Int -> a -> f b over all as in the given PatchIntMap a (that is, all inserts/updates), producing a f (PatchIntMap b). patchIntMapNewElements :: PatchIntMap a -> [a] Source # Extract all as inserted/updated by the given PatchIntMap a. Convert the given PatchIntMap a into an IntMap a with all the inserts/updates in the given patch. newtype PatchMap k v Source # A set of changes to a Map. Any element may be inserted/updated or deleted. Insertions are represented as values wrapped in Just, while deletions are represented as Nothings Constructors  PatchMap FieldsunPatchMap :: Map k (Maybe v) Instances  Source # Instance detailsDefined in Data.Patch.Map Methodsimap :: (k -> a -> b) -> PatchMap k a -> PatchMap k b #imapped :: IndexedSetter k (PatchMap k a) (PatchMap k b) a b # Source # Instance detailsDefined in Data.Patch.Map MethodsifoldMap :: Monoid m => (k -> a -> m) -> PatchMap k a -> m #ifolded :: IndexedFold k (PatchMap k a) a #ifoldr :: (k -> a -> b -> b) -> b -> PatchMap k a -> b #ifoldl :: (k -> b -> a -> b) -> b -> PatchMap k a -> b #ifoldr' :: (k -> a -> b -> b) -> b -> PatchMap k a -> b #ifoldl' :: (k -> b -> a -> b) -> b -> PatchMap k a -> b # Source # Instance detailsDefined in Data.Patch.Map Methodsitraverse :: Applicative f => (k -> a -> f b) -> PatchMap k a -> f (PatchMap k b) #itraversed :: IndexedTraversal k (PatchMap k a) (PatchMap k b) a b # Source # fmapping a PatchMap will alter all of the values it will insert. Deletions are unaffected. Instance detailsDefined in Data.Patch.Map Methodsfmap :: (a -> b) -> PatchMap k a -> PatchMap k b #(<$) :: a -> PatchMap k b -> PatchMap k a # Source # Instance detailsDefined in Data.Patch.Map Methodsfold :: Monoid m => PatchMap k m -> m #foldMap :: Monoid m => (a -> m) -> PatchMap k a -> m #foldr :: (a -> b -> b) -> b -> PatchMap k a -> b #foldr' :: (a -> b -> b) -> b -> PatchMap k a -> b #foldl :: (b -> a -> b) -> b -> PatchMap k a -> b #foldl' :: (b -> a -> b) -> b -> PatchMap k a -> b #foldr1 :: (a -> a -> a) -> PatchMap k a -> a #foldl1 :: (a -> a -> a) -> PatchMap k a -> a #toList :: PatchMap k a -> [a] #null :: PatchMap k a -> Bool #length :: PatchMap k a -> Int #elem :: Eq a => a -> PatchMap k a -> Bool #maximum :: Ord a => PatchMap k a -> a #minimum :: Ord a => PatchMap k a -> a #sum :: Num a => PatchMap k a -> a #product :: Num a => PatchMap k a -> a # Source # Instance detailsDefined in Data.Patch.Map Methodstraverse :: Applicative f => (a -> f b) -> PatchMap k a -> f (PatchMap k b) #sequenceA :: Applicative f => PatchMap k (f a) -> f (PatchMap k a) #mapM :: Monad m => (a -> m b) -> PatchMap k a -> m (PatchMap k b) #sequence :: Monad m => PatchMap k (m a) -> m (PatchMap k a) # (Eq k, Eq v) => Eq (PatchMap k v) Source # Instance detailsDefined in Data.Patch.Map Methods(==) :: PatchMap k v -> PatchMap k v -> Bool #(/=) :: PatchMap k v -> PatchMap k v -> Bool # (Ord k, Ord v) => Ord (PatchMap k v) Source # Instance detailsDefined in Data.Patch.Map Methodscompare :: PatchMap k v -> PatchMap k v -> Ordering #(<) :: PatchMap k v -> PatchMap k v -> Bool #(<=) :: PatchMap k v -> PatchMap k v -> Bool #(>) :: PatchMap k v -> PatchMap k v -> Bool #(>=) :: PatchMap k v -> PatchMap k v -> Bool #max :: PatchMap k v -> PatchMap k v -> PatchMap k v #min :: PatchMap k v -> PatchMap k v -> PatchMap k v # (Ord k, Read k, Read v) => Read (PatchMap k v) Source # Instance detailsDefined in Data.Patch.Map MethodsreadsPrec :: Int -> ReadS (PatchMap k v) #readList :: ReadS [PatchMap k v] #readPrec :: ReadPrec (PatchMap k v) # (Show k, Show v) => Show (PatchMap k v) Source # Instance detailsDefined in Data.Patch.Map MethodsshowsPrec :: Int -> PatchMap k v -> ShowS #show :: PatchMap k v -> String #showList :: [PatchMap k v] -> ShowS # Ord k => Semigroup (PatchMap k v) Source # a <> b will apply the changes of b and then apply the changes of a. If the same key is modified by both patches, the one on the left will take precedence. Instance detailsDefined in Data.Patch.Map Methods(<>) :: PatchMap k v -> PatchMap k v -> PatchMap k v #sconcat :: NonEmpty (PatchMap k v) -> PatchMap k v #stimes :: Integral b => b -> PatchMap k v -> PatchMap k v # Ord k => Monoid (PatchMap k v) Source # The empty PatchMap contains no insertions or deletions Instance detailsDefined in Data.Patch.Map Methodsmempty :: PatchMap k v #mappend :: PatchMap k v -> PatchMap k v -> PatchMap k v #mconcat :: [PatchMap k v] -> PatchMap k v # Wrapped (PatchMap k v) Source # Instance detailsDefined in Data.Patch.Map Associated Typestype Unwrapped (PatchMap k v) :: Type # Methods_Wrapped' :: Iso' (PatchMap k v) (Unwrapped (PatchMap k v)) # Ord k => DecidablyEmpty (PatchMap k v) Source # Instance detailsDefined in Data.Patch.Map MethodsisEmpty :: PatchMap k v -> Bool Source # Ord k => Patch (PatchMap k v) Source # Apply the insertions or deletions to a given Map. Instance detailsDefined in Data.Patch.Map Associated Typestype PatchTarget (PatchMap k v) :: Type Source # Methodsapply :: PatchMap k v -> PatchTarget (PatchMap k v) -> Maybe (PatchTarget (PatchMap k v)) Source # PatchMap k1 v1 ~ t => Rewrapped (PatchMap k2 v2) t Source # Instance detailsDefined in Data.Patch.Map type Unwrapped (PatchMap k v) Source # Instance detailsDefined in Data.Patch.Map type Unwrapped (PatchMap k v) = Map k (Maybe v) type PatchTarget (PatchMap k v) Source # Instance detailsDefined in Data.Patch.Map type PatchTarget (PatchMap k v) = Map k v

patchMapNewElements :: PatchMap k v -> [v] Source #

Returns all the new elements that will be added to the Map

patchMapNewElementsMap :: PatchMap k v -> Map k v Source #

Returns all the new elements that will be added to the Map

newtype PatchDMap k v Source #

A set of changes to a DMap. Any element may be inserted/updated or deleted. Insertions are represented as ComposeMaybe (Just value), while deletions are represented as ComposeMaybe Nothing.

Constructors

 PatchDMap FieldsunPatchDMap :: DMap k (ComposeMaybe v)
Instances
 GCompare k2 => Semigroup (PatchDMap k2 v) Source # Instance detailsDefined in Data.Patch.DMap Methods(<>) :: PatchDMap k2 v -> PatchDMap k2 v -> PatchDMap k2 v #sconcat :: NonEmpty (PatchDMap k2 v) -> PatchDMap k2 v #stimes :: Integral b => b -> PatchDMap k2 v -> PatchDMap k2 v # GCompare k2 => Monoid (PatchDMap k2 v) Source # Instance detailsDefined in Data.Patch.DMap Methodsmempty :: PatchDMap k2 v #mappend :: PatchDMap k2 v -> PatchDMap k2 v -> PatchDMap k2 v #mconcat :: [PatchDMap k2 v] -> PatchDMap k2 v # GCompare k2 => DecidablyEmpty (PatchDMap k2 v) Source # Instance detailsDefined in Data.Patch.DMap MethodsisEmpty :: PatchDMap k2 v -> Bool Source # GCompare k2 => Patch (PatchDMap k2 v) Source # Apply the insertions or deletions to a given DMap. Instance detailsDefined in Data.Patch.DMap Associated Typestype PatchTarget (PatchDMap k2 v) :: Type Source # Methodsapply :: PatchDMap k2 v -> PatchTarget (PatchDMap k2 v) -> Maybe (PatchTarget (PatchDMap k2 v)) Source # type PatchTarget (PatchDMap k2 v) Source # Instance detailsDefined in Data.Patch.DMap type PatchTarget (PatchDMap k2 v) = DMap k2 v

mapPatchDMap :: (forall a. v a -> v' a) -> PatchDMap k v -> PatchDMap k v' Source #

Map a function v a -> v' a over any inserts/updates in the given PatchDMap k v to produce a PatchDMap k v'.

traversePatchDMap :: Applicative f => (forall a. v a -> f (v' a)) -> PatchDMap k v -> f (PatchDMap k v') Source #

Map an effectful function v a -> f (v' a) over any inserts/updates in the given PatchDMap k v to produce a PatchDMap k v'.

traversePatchDMapWithKey :: Applicative m => (forall a. k a -> v a -> m (v' a)) -> PatchDMap k v -> m (PatchDMap k v') Source #

Map an effectful function k a -> v a -> f (v' a) over any inserts/updates in the given PatchDMap k v to produce a PatchDMap k v'.

weakenPatchDMapWith :: (forall a. v a -> v') -> PatchDMap k v -> PatchMap (Some k) v' Source #

Weaken a PatchDMap k v to a PatchMap (Some k) v' using a function v a -> v' to weaken each value contained in the patch.

patchDMapToPatchMapWith :: (v a -> v') -> PatchDMap (Const2 k a) v -> PatchMap k v' Source #

Convert a weak PatchDMap (Const2 k a) v where the a is known by way of the Const2 into a PatchMap k v' using a rank 1 function v a -> v'.

const2PatchDMapWith :: forall k v v' a. (v -> v' a) -> PatchMap k v -> PatchDMap (Const2 k a) v' Source #

Convert a PatchMap k v into a PatchDMap (Const2 k a) v' using a function v -> v' a.

const2IntPatchDMapWith :: forall v f a. (v -> f a) -> PatchIntMap v -> PatchDMap (Const2 Key a) f Source #

Convert a PatchIntMap v into a PatchDMap (Const2 Int a) v' using a function v -> v' a.

data PatchMapWithMove k v Source #

Patch a Map with additions, deletions, and moves. Invariant: If key k1 is coming from From_Move k2, then key k2 should be going to Just k1, and vice versa. There should never be any unpaired From/To keys.

Instances
 Source # Instance detailsDefined in Data.Patch.MapWithMove Methodsimap :: (k -> a -> b) -> PatchMapWithMove k a -> PatchMapWithMove k b #imapped :: IndexedSetter k (PatchMapWithMove k a) (PatchMapWithMove k b) a b # Source # Instance detailsDefined in Data.Patch.MapWithMove MethodsifoldMap :: Monoid m => (k -> a -> m) -> PatchMapWithMove k a -> m #ifolded :: IndexedFold k (PatchMapWithMove k a) a #ifoldr :: (k -> a -> b -> b) -> b -> PatchMapWithMove k a -> b #ifoldl :: (k -> b -> a -> b) -> b -> PatchMapWithMove k a -> b #ifoldr' :: (k -> a -> b -> b) -> b -> PatchMapWithMove k a -> b #ifoldl' :: (k -> b -> a -> b) -> b -> PatchMapWithMove k a -> b # Source # Instance detailsDefined in Data.Patch.MapWithMove Methodsitraverse :: Applicative f => (k -> a -> f b) -> PatchMapWithMove k a -> f (PatchMapWithMove k b) #itraversed :: IndexedTraversal k (PatchMapWithMove k a) (PatchMapWithMove k b) a b # Source # Instance detailsDefined in Data.Patch.MapWithMove Methodsfmap :: (a -> b) -> PatchMapWithMove k a -> PatchMapWithMove k b #(<\$) :: a -> PatchMapWithMove k b -> PatchMapWithMove k a # Source # Instance detailsDefined in Data.Patch.MapWithMove Methodsfold :: Monoid m => PatchMapWithMove k m -> m #foldMap :: Monoid m => (a -> m) -> PatchMapWithMove k a -> m #foldr :: (a -> b -> b) -> b -> PatchMapWithMove k a -> b #foldr' :: (a -> b -> b) -> b -> PatchMapWithMove k a -> b #foldl :: (b -> a -> b) -> b -> PatchMapWithMove k a -> b #foldl' :: (b -> a -> b) -> b -> PatchMapWithMove k a -> b #foldr1 :: (a -> a -> a) -> PatchMapWithMove k a -> a #foldl1 :: (a -> a -> a) -> PatchMapWithMove k a -> a #toList :: PatchMapWithMove k a -> [a] #null :: PatchMapWithMove k a -> Bool #length :: PatchMapWithMove k a -> Int #elem :: Eq a => a -> PatchMapWithMove k a -> Bool #maximum :: Ord a => PatchMapWithMove k a -> a #minimum :: Ord a => PatchMapWithMove k a -> a #sum :: Num a => PatchMapWithMove k a -> a #product :: Num a => PatchMapWithMove k a -> a # Source # Instance detailsDefined in Data.Patch.MapWithMove Methodstraverse :: Applicative f => (a -> f b) -> PatchMapWithMove k a -> f (PatchMapWithMove k b) #sequenceA :: Applicative f => PatchMapWithMove k (f a) -> f (PatchMapWithMove k a) #mapM :: Monad m => (a -> m b) -> PatchMapWithMove k a -> m (PatchMapWithMove k b) #sequence :: Monad m => PatchMapWithMove k (m a) -> m (PatchMapWithMove k a) # (Eq k, Eq v) => Eq (PatchMapWithMove k v) Source # Instance detailsDefined in Data.Patch.MapWithMove Methods(==) :: PatchMapWithMove k v -> PatchMapWithMove k v -> Bool #(/=) :: PatchMapWithMove k v -> PatchMapWithMove k v -> Bool # (Ord k, Ord v) => Ord (PatchMapWithMove k v) Source # Instance detailsDefined in Data.Patch.MapWithMove Methodscompare :: PatchMapWithMove k v -> PatchMapWithMove k v -> Ordering #(<) :: PatchMapWithMove k v -> PatchMapWithMove k v -> Bool #(<=) :: PatchMapWithMove k v -> PatchMapWithMove k v -> Bool #(>) :: PatchMapWithMove k v -> PatchMapWithMove k v -> Bool #(>=) :: PatchMapWithMove k v -> PatchMapWithMove k v -> Bool #max :: PatchMapWithMove k v -> PatchMapWithMove k v -> PatchMapWithMove k v #min :: PatchMapWithMove k v -> PatchMapWithMove k v -> PatchMapWithMove k v # (Ord k, Read k, Read v) => Read (PatchMapWithMove k v) Source # Instance detailsDefined in Data.Patch.MapWithMove MethodsreadsPrec :: Int -> ReadS (PatchMapWithMove k v) # (Show k, Show v) => Show (PatchMapWithMove k v) Source # Instance detailsDefined in Data.Patch.MapWithMove MethodsshowsPrec :: Int -> PatchMapWithMove k v -> ShowS #show :: PatchMapWithMove k v -> String #showList :: [PatchMapWithMove k v] -> ShowS # Ord k => Semigroup (PatchMapWithMove k v) Source # Compose patches having the same effect as applying the patches in turn: applyAlways (p <> q) == applyAlways p . applyAlways q Instance detailsDefined in Data.Patch.MapWithMove Methods(<>) :: PatchMapWithMove k v -> PatchMapWithMove k v -> PatchMapWithMove k v #sconcat :: NonEmpty (PatchMapWithMove k v) -> PatchMapWithMove k v #stimes :: Integral b => b -> PatchMapWithMove k v -> PatchMapWithMove k v # Ord k => Monoid (PatchMapWithMove k v) Source # Compose patches having the same effect as applying the patches in turn: applyAlways (p <> q) == applyAlways p . applyAlways q Instance detailsDefined in Data.Patch.MapWithMove Methodsmappend :: PatchMapWithMove k v -> PatchMapWithMove k v -> PatchMapWithMove k v #mconcat :: [PatchMapWithMove k v] -> PatchMapWithMove k v # Source # Instance detailsDefined in Data.Patch.MapWithMove Associated Typestype Unwrapped (PatchMapWithMove k v) :: Type # Methods_Wrapped' :: Iso' (PatchMapWithMove k v) (Unwrapped (PatchMapWithMove k v)) # Ord k => Patch (PatchMapWithMove k v) Source # Apply the insertions, deletions, and moves to a given Map Instance detailsDefined in Data.Patch.MapWithMove Associated Typestype PatchTarget (PatchMapWithMove k v) :: Type Source # Methodsapply :: PatchMapWithMove k v -> PatchTarget (PatchMapWithMove k v) -> Maybe (PatchTarget (PatchMapWithMove k v)) Source # PatchMapWithMove k1 v1 ~ t => Rewrapped (PatchMapWithMove k2 v2) t Source # Instance detailsDefined in Data.Patch.MapWithMove type Unwrapped (PatchMapWithMove k v) Source # Instance detailsDefined in Data.Patch.MapWithMove type Unwrapped (PatchMapWithMove k v) = Map k (NodeInfo k v) type PatchTarget (PatchMapWithMove k v) Source # Instance detailsDefined in Data.Patch.MapWithMove type PatchTarget (PatchMapWithMove k v) = Map k v

unsafePatchMapWithMove :: Map k (NodeInfo k v) -> PatchMapWithMove k v Source #

Wrap a Map k (NodeInfo k v) representing patch changes into a PatchMapWithMove k v, without checking any invariants.

Warning: when using this function, you must ensure that the invariants of PatchMapWithMove are preserved; they will not be checked.

Returns all the new elements that will be added to the Map.

Return a Map k v with all the inserts/updates from the given PatchMapWithMove k v.

data PatchDMapWithMove k v Source #

Like PatchMapWithMove, but for DMap. Each key carries a NodeInfo which describes how it will be changed by the patch and connects move sources and destinations.

Invariants:

• A key should not move to itself.
• A move should always be represented with both the destination key (as a From_Move) and the source key (as a ComposeMaybe (Just destination))
Instances
 (GEq k2, Has' Eq k2 (NodeInfo k2 v)) => Eq (PatchDMapWithMove k2 v) Source # Test whether two PatchDMapWithMove k v contain the same patch operations. Instance detailsDefined in Data.Patch.DMapWithMove Methods(==) :: PatchDMapWithMove k2 v -> PatchDMapWithMove k2 v -> Bool #(/=) :: PatchDMapWithMove k2 v -> PatchDMapWithMove k2 v -> Bool # GCompare k2 => Semigroup (PatchDMapWithMove k2 v) Source # Compose patches having the same effect as applying the patches in turn: applyAlways (p <> q) == applyAlways p . applyAlways q Instance detailsDefined in Data.Patch.DMapWithMove Methods(<>) :: PatchDMapWithMove k2 v -> PatchDMapWithMove k2 v -> PatchDMapWithMove k2 v #sconcat :: NonEmpty (PatchDMapWithMove k2 v) -> PatchDMapWithMove k2 v #stimes :: Integral b => b -> PatchDMapWithMove k2 v -> PatchDMapWithMove k2 v # GCompare k2 => Monoid (PatchDMapWithMove k2 v) Source # Compose patches having the same effect as applying the patches in turn: applyAlways (p <> q) == applyAlways p . applyAlways q Instance detailsDefined in Data.Patch.DMapWithMove Methodsmempty :: PatchDMapWithMove k2 v #mappend :: PatchDMapWithMove k2 v -> PatchDMapWithMove k2 v -> PatchDMapWithMove k2 v #mconcat :: [PatchDMapWithMove k2 v] -> PatchDMapWithMove k2 v # GCompare k2 => DecidablyEmpty (PatchDMapWithMove k2 v) Source # Instance detailsDefined in Data.Patch.DMapWithMove MethodsisEmpty :: PatchDMapWithMove k2 v -> Bool Source # GCompare k2 => Patch (PatchDMapWithMove k2 v) Source # Apply the insertions, deletions, and moves to a given DMap. Instance detailsDefined in Data.Patch.DMapWithMove Associated Typestype PatchTarget (PatchDMapWithMove k2 v) :: Type Source # Methodsapply :: PatchDMapWithMove k2 v -> PatchTarget (PatchDMapWithMove k2 v) -> Maybe (PatchTarget (PatchDMapWithMove k2 v)) Source # type PatchTarget (PatchDMapWithMove k2 v) Source # Instance detailsDefined in Data.Patch.DMapWithMove type PatchTarget (PatchDMapWithMove k2 v) = DMap k2 v

unPatchDMapWithMove :: PatchDMapWithMove k v -> DMap k (NodeInfo k v) Source #

Extract the DMap representing the patch changes from the PatchDMapWithMove.

unsafePatchDMapWithMove :: DMap k (NodeInfo k v) -> PatchDMapWithMove k v Source #

Wrap a DMap representing patch changes into a PatchDMapWithMove, without checking any invariants.

Warning: when using this function, you must ensure that the invariants of PatchDMapWithMove are preserved; they will not be checked.

mapPatchDMapWithMove :: forall k v v'. (forall a. v a -> v' a) -> PatchDMapWithMove k v -> PatchDMapWithMove k v' Source #

Map a natural transform v -> v' over the given patch, transforming PatchDMapWithMove k v into PatchDMapWithMove k v'.

traversePatchDMapWithMoveWithKey :: forall m k v v'. Applicative m => (forall a. k a -> v a -> m (v' a)) -> PatchDMapWithMove k v -> m (PatchDMapWithMove k v') Source #

Map an effectful function forall a. k a -> v a -> m (v ' a) over the given patch, transforming PatchDMapWithMove k v into m (PatchDMapWithMove k v').

weakenPatchDMapWithMoveWith :: forall k v v'. (forall a. v a -> v') -> PatchDMapWithMove k v -> PatchMapWithMove (Some k) v' Source #

Weaken a PatchDMapWithMove to a PatchMapWithMove by weakening the keys from k a to Some k and applying a given weakening function v a -> v' to values.

patchDMapWithMoveToPatchMapWithMoveWith :: forall k v v' a. (v a -> v') -> PatchDMapWithMove (Const2 k a) v -> PatchMapWithMove k v' Source #

Weaken a PatchDMapWithMove (Const2 k a) v to a PatchMapWithMove k v'. Weaken is in scare quotes because the Const2 has already disabled any dependency in the typing and all points are already a, hence the function to map each value to v' is not higher rank.

const2PatchDMapWithMoveWith :: forall k v v' a. (v -> v' a) -> PatchMapWithMove k v -> PatchDMapWithMove (Const2 k a) v' Source #

Strengthen a PatchMapWithMove k v into a 'PatchDMapWithMove (Const2 k a); that is, turn a non-dependently-typed patch into a dependently typed one but which always has a constant key type represented by Const2. Apply the given function to each v to produce a v' a. Completemented by patchDMapWithMoveToPatchMapWithMoveWith