diff-containers-1.3.0.0: Diffs for containers
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Map.Diff.Strict.Internal

Description

See the module documentation for Data.Map.Diff.Strict.

Synopsis

Types

data Delta v Source #

A change to a value in a key-value store.

Constructors

Insert !v 
Delete 

Instances

Instances details
Foldable Delta Source # 
Instance details

Defined in Data.Map.Diff.Strict.Internal

Methods

fold :: Monoid m => Delta m -> m #

foldMap :: Monoid m => (a -> m) -> Delta a -> m #

foldMap' :: Monoid m => (a -> m) -> Delta a -> m #

foldr :: (a -> b -> b) -> b -> Delta a -> b #

foldr' :: (a -> b -> b) -> b -> Delta a -> b #

foldl :: (b -> a -> b) -> b -> Delta a -> b #

foldl' :: (b -> a -> b) -> b -> Delta a -> b #

foldr1 :: (a -> a -> a) -> Delta a -> a #

foldl1 :: (a -> a -> a) -> Delta a -> a #

toList :: Delta a -> [a] #

null :: Delta a -> Bool #

length :: Delta a -> Int #

elem :: Eq a => a -> Delta a -> Bool #

maximum :: Ord a => Delta a -> a #

minimum :: Ord a => Delta a -> a #

sum :: Num a => Delta a -> a #

product :: Num a => Delta a -> a #

Traversable Delta Source # 
Instance details

Defined in Data.Map.Diff.Strict.Internal

Methods

traverse :: Applicative f => (a -> f b) -> Delta a -> f (Delta b) #

sequenceA :: Applicative f => Delta (f a) -> f (Delta a) #

mapM :: Monad m => (a -> m b) -> Delta a -> m (Delta b) #

sequence :: Monad m => Delta (m a) -> m (Delta a) #

Functor Delta Source # 
Instance details

Defined in Data.Map.Diff.Strict.Internal

Methods

fmap :: (a -> b) -> Delta a -> Delta b #

(<$) :: a -> Delta b -> Delta a #

Generic (Delta v) Source # 
Instance details

Defined in Data.Map.Diff.Strict.Internal

Associated Types

type Rep (Delta v) :: Type -> Type #

Methods

from :: Delta v -> Rep (Delta v) x #

to :: Rep (Delta v) x -> Delta v #

Show v => Show (Delta v) Source # 
Instance details

Defined in Data.Map.Diff.Strict.Internal

Methods

showsPrec :: Int -> Delta v -> ShowS #

show :: Delta v -> String #

showList :: [Delta v] -> ShowS #

Eq v => Eq (Delta v) Source # 
Instance details

Defined in Data.Map.Diff.Strict.Internal

Methods

(==) :: Delta v -> Delta v -> Bool #

(/=) :: Delta v -> Delta v -> Bool #

NoThunks v => NoThunks (Delta v) Source # 
Instance details

Defined in Data.Map.Diff.Strict.Internal

type Rep (Delta v) Source # 
Instance details

Defined in Data.Map.Diff.Strict.Internal

type Rep (Delta v) = D1 ('MetaData "Delta" "Data.Map.Diff.Strict.Internal" "diff-containers-1.3.0.0-inplace" 'False) (C1 ('MetaCons "Insert" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 v)) :+: C1 ('MetaCons "Delete" 'PrefixI 'False) (U1 :: Type -> Type))

newtype DeltaHistory v Source #

A non-empty history of changes to a value in a key-value store.

A history has an implicit sense of ordering according to time: from left to right. This means that the leftmost element in the history is the earliest change, while the rightmost element in the history is the latest change.

Constructors

DeltaHistory 

Fields

Instances

Instances details
Functor DeltaHistory Source # 
Instance details

Defined in Data.Map.Diff.Strict.Internal

Methods

fmap :: (a -> b) -> DeltaHistory a -> DeltaHistory b #

(<$) :: a -> DeltaHistory b -> DeltaHistory a #

Semigroup (DeltaHistory v) Source # 
Instance details

Defined in Data.Map.Diff.Strict.Internal

Generic (DeltaHistory v) Source # 
Instance details

Defined in Data.Map.Diff.Strict.Internal

Associated Types

type Rep (DeltaHistory v) :: Type -> Type #

Methods

from :: DeltaHistory v -> Rep (DeltaHistory v) x #

to :: Rep (DeltaHistory v) x -> DeltaHistory v #

Show v => Show (DeltaHistory v) Source # 
Instance details

Defined in Data.Map.Diff.Strict.Internal

Eq v => Eq (DeltaHistory v) Source # 
Instance details

Defined in Data.Map.Diff.Strict.Internal

NoThunks v => NoThunks (DeltaHistory v) Source # 
Instance details

Defined in Data.Map.Diff.Strict.Internal

type Rep (DeltaHistory v) Source # 
Instance details

Defined in Data.Map.Diff.Strict.Internal

type Rep (DeltaHistory v) = D1 ('MetaData "DeltaHistory" "Data.Map.Diff.Strict.Internal" "diff-containers-1.3.0.0-inplace" 'True) (C1 ('MetaCons "DeltaHistory" 'PrefixI 'True) (S1 ('MetaSel ('Just "getDeltaHistory") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (NESeq (Delta v)))))

newtype Diff k v Source #

A diff for key-value stores.

Constructors

Diff (Map k (DeltaHistory v)) 

Instances

Instances details
Functor (Diff k) Source #

Custom Functor instance, since Functor (Map k) is actually the Functor instance for a lazy Map.

Instance details

Defined in Data.Map.Diff.Strict.Internal

Methods

fmap :: (a -> b) -> Diff k a -> Diff k b #

(<$) :: a -> Diff k b -> Diff k a #

Ord k => Monoid (Diff k v) Source # 
Instance details

Defined in Data.Map.Diff.Strict.Internal

Methods

mempty :: Diff k v #

mappend :: Diff k v -> Diff k v -> Diff k v #

mconcat :: [Diff k v] -> Diff k v #

Ord k => Semigroup (Diff k v) Source # 
Instance details

Defined in Data.Map.Diff.Strict.Internal

Methods

(<>) :: Diff k v -> Diff k v -> Diff k v #

sconcat :: NonEmpty (Diff k v) -> Diff k v #

stimes :: Integral b => b -> Diff k v -> Diff k v #

Generic (Diff k v) Source # 
Instance details

Defined in Data.Map.Diff.Strict.Internal

Associated Types

type Rep (Diff k v) :: Type -> Type #

Methods

from :: Diff k v -> Rep (Diff k v) x #

to :: Rep (Diff k v) x -> Diff k v #

(Show k, Show v) => Show (Diff k v) Source # 
Instance details

Defined in Data.Map.Diff.Strict.Internal

Methods

showsPrec :: Int -> Diff k v -> ShowS #

show :: Diff k v -> String #

showList :: [Diff k v] -> ShowS #

(Eq k, Eq v) => Eq (Diff k v) Source # 
Instance details

Defined in Data.Map.Diff.Strict.Internal

Methods

(==) :: Diff k v -> Diff k v -> Bool #

(/=) :: Diff k v -> Diff k v -> Bool #

(Ord k, Eq v) => LeftCancellative (Diff k v) Source # 
Instance details

Defined in Data.Map.Diff.Strict.Internal

(Ord k, Eq v) => LeftReductive (Diff k v) Source # 
Instance details

Defined in Data.Map.Diff.Strict.Internal

Methods

isPrefixOf :: Diff k v -> Diff k v -> Bool #

stripPrefix :: Diff k v -> Diff k v -> Maybe (Diff k v) #

(Ord k, Eq v) => RightCancellative (Diff k v) Source # 
Instance details

Defined in Data.Map.Diff.Strict.Internal

(Ord k, Eq v) => RightReductive (Diff k v) Source # 
Instance details

Defined in Data.Map.Diff.Strict.Internal

Methods

isSuffixOf :: Diff k v -> Diff k v -> Bool #

stripSuffix :: Diff k v -> Diff k v -> Maybe (Diff k v) #

(NoThunks k, NoThunks v) => NoThunks (Diff k v) Source # 
Instance details

Defined in Data.Map.Diff.Strict.Internal

type Rep (Diff k v) Source # 
Instance details

Defined in Data.Map.Diff.Strict.Internal

type Rep (Diff k v) = D1 ('MetaData "Diff" "Data.Map.Diff.Strict.Internal" "diff-containers-1.3.0.0-inplace" 'True) (C1 ('MetaCons "Diff" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map k (DeltaHistory v)))))

Conversion

keysSet :: Diff k v -> Set k Source #

Construction

diff :: (Ord k, Eq v) => Map k v -> Map k v -> Diff k v Source #

Compute the difference between Maps.

Maps

fromMap :: Map k (Delta v) -> Diff k v Source #

fromMap m creates a Diff from the inserts and deletes in m.

fromMapDeletes :: Map k v -> Diff k v Source #

fromMapDeletes m creates a Diff that deletes all values in m.

fromMapInserts :: Map k v -> Diff k v Source #

fromMapInserts m creates a Diff that inserts all values in m.

Lists

fromList :: Ord k => [(k, Delta v)] -> Diff k v Source #

fromList xs creates a Diff from the inserts and deletes in xs.

fromListDeletes :: Ord k => [k] -> Diff k v Source #

fromListDeletes xs creates a Diff that deletes all values in xs.

fromListInserts :: Ord k => [(k, v)] -> Diff k v Source #

fromListInserts xs creates a Diff that inserts all values in xs.

Delta history

Deconstruction

Delta history

Query

Size

null :: Diff k v -> Bool Source #

numDeletes :: Diff k v -> Int Source #

numDeletes d returns the number of deletes in the diff d.

Note: that is, the number of diff histories that have deletes as their last change.

numInserts :: Diff k v -> Int Source #

numInserts d returns the number of inserts in the diff d.

Note: that is, the number of diff histories that have inserts as their last change.

size :: Diff k v -> Int Source #

Applying diffs

applyDiff :: Ord k => Map k v -> Diff k v -> Map k v Source #

Applies a diff to a Map.

applyDiffForKeys :: Ord k => Map k v -> Set k -> Diff k v -> Map k v Source #

Applies a diff to a Map for a specific set of keys.

Folds and traversals

foldMapDelta :: Monoid m => (Delta v -> m) -> Diff k v -> m Source #

foldMap over the last delta in each delta history.

mapMaybeDiff :: (v -> Maybe v') -> Diff k v -> Diff k v' Source #

traverseDeltaWithKey_ :: Applicative t => (k -> Delta v -> t a) -> Diff k v -> t () Source #

Traversal with keys over the last delta in each delta history.

Filter

filterOnlyKey :: (k -> Bool) -> Diff k v -> Diff k v Source #