Safe Haskell | None |
---|---|
Language | Haskell98 |
Synopsis
- newtype AdditivePatch p = AdditivePatch {
- unAdditivePatch :: p
- class Semigroup q => Additive q
- class (Semigroup q, Monoid q) => Group q where
- class Patch p where
- type PatchTarget p :: *
- apply :: p -> PatchTarget p -> Maybe (PatchTarget p)
- applyAlways :: Patch p => p -> PatchTarget p -> PatchTarget p
- composePatchFunctions :: (Patch p, Semigroup p) => (PatchTarget p -> p) -> (PatchTarget p -> p) -> PatchTarget p -> p
- newtype PatchIntMap a = PatchIntMap {
- unPatchIntMap :: IntMap (Maybe a)
- mapIntMapPatchWithKey :: (Int -> a -> b) -> PatchIntMap a -> PatchIntMap b
- traverseIntMapPatchWithKey :: Applicative f => (Int -> a -> f b) -> PatchIntMap a -> f (PatchIntMap b)
- patchIntMapNewElements :: PatchIntMap a -> [a]
- patchIntMapNewElementsMap :: PatchIntMap a -> IntMap a
- newtype PatchMap k v = PatchMap {
- unPatchMap :: Map k (Maybe v)
- patchMapNewElements :: PatchMap k v -> [v]
- patchMapNewElementsMap :: PatchMap k v -> Map k v
- newtype PatchDMap k v = PatchDMap {
- unPatchDMap :: DMap k (ComposeMaybe v)
- mapPatchDMap :: (forall a. v a -> v' a) -> PatchDMap k v -> PatchDMap k v'
- traversePatchDMap :: Applicative f => (forall a. v a -> f (v' a)) -> PatchDMap k v -> f (PatchDMap k v')
- traversePatchDMapWithKey :: Applicative m => (forall a. k a -> v a -> m (v' a)) -> PatchDMap k v -> m (PatchDMap k v')
- weakenPatchDMapWith :: (forall a. v a -> v') -> PatchDMap k v -> PatchMap (Some k) v'
- patchDMapToPatchMapWith :: (v a -> v') -> PatchDMap (Const2 k a) v -> PatchMap k v'
- const2PatchDMapWith :: forall k v v' a. (v -> v' a) -> PatchMap k v -> PatchDMap (Const2 k a) v'
- const2IntPatchDMapWith :: forall v f a. (v -> f a) -> PatchIntMap v -> PatchDMap (Const2 Key a) f
- data PatchMapWithMove k v
- unsafePatchMapWithMove :: Map k (NodeInfo k v) -> PatchMapWithMove k v
- patchMapWithMoveNewElements :: PatchMapWithMove k v -> [v]
- patchMapWithMoveNewElementsMap :: PatchMapWithMove k v -> Map k v
- data PatchDMapWithMove k v
- unPatchDMapWithMove :: PatchDMapWithMove k v -> DMap k (NodeInfo k v)
- unsafePatchDMapWithMove :: DMap k (NodeInfo k v) -> PatchDMapWithMove k v
- mapPatchDMapWithMove :: forall k v v'. (forall a. v a -> v' a) -> PatchDMapWithMove k v -> 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')
- weakenPatchDMapWithMoveWith :: forall k v v'. (forall a. v a -> v') -> PatchDMapWithMove k v -> PatchMapWithMove (Some k) v'
- patchDMapWithMoveToPatchMapWithMoveWith :: forall k v v' a. (v a -> v') -> PatchDMapWithMove (Const2 k a) v -> PatchMapWithMove k v'
- const2PatchDMapWithMoveWith :: forall k v v' a. (v -> v' a) -> PatchMapWithMove k v -> PatchDMapWithMove (Const2 k a) v'
Documentation
newtype AdditivePatch p Source #
Instances
Additive p => Patch (AdditivePatch p) Source # | |
Defined in Data.Patch type PatchTarget (AdditivePatch p) :: Type Source # apply :: AdditivePatch p -> PatchTarget (AdditivePatch p) -> Maybe (PatchTarget (AdditivePatch p)) Source # | |
type PatchTarget (AdditivePatch p) Source # | |
Defined in Data.Patch |
class Semigroup q => Additive q Source #
Instances
Additive () Source # | |
Defined in Data.Patch | |
Additive a => Additive (Identity a) Source # | |
Defined in Data.Patch | |
Additive b => Additive (a -> b) Source # | |
Defined in Data.Patch | |
(Additive a, Additive b) => Additive (a, b) Source # | |
Defined in Data.Patch | |
Additive (Proxy x) Source # | |
Defined in Data.Patch | |
(Ord k, Additive q) => Additive (MonoidalMap k q) Source # | |
Defined in Data.Patch | |
Additive a => Additive (Const a x) Source # | |
Defined in Data.Patch | |
(Additive (f a), Additive (g a)) => Additive ((f :*: g) a) Source # | |
Defined in Data.Patch | |
Additive (f (g a)) => Additive ((f :.: g) a) Source # | |
Defined in Data.Patch |
class (Semigroup q, Monoid q) => Group q where Source #
Instances
Group () Source # | Trivial group. |
Group a => Group (Identity a) Source # | Ideitnty lifts groups pointwise (at only one point) |
Group b => Group (a -> b) Source # | Functions lift groups pointwise. |
(Group a, Group b) => Group (a, b) Source # | Product group. A Pair of groups gives rise to a group |
Group (Proxy x) Source # | Trivial group, Functor style |
(Ord k, Group q) => Group (MonoidalMap k q) Source # | |
Defined in Data.Patch negateG :: 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. |
(Group (f a), Group (g a)) => Group ((f :*: g) a) Source # | Product of groups, Functor style. |
Group (f (g a)) => Group ((f :.: g) a) 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
.
type PatchTarget p :: * Source #
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
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.
PatchIntMap | |
|
Instances
mapIntMapPatchWithKey :: (Int -> a -> b) -> PatchIntMap a -> PatchIntMap b Source #
Map a function Int -> a -> b
over all a
s in the given
(that is, all inserts/updates), producing a PatchIntMap
aPatchIntMap b
.
traverseIntMapPatchWithKey :: Applicative f => (Int -> a -> f b) -> PatchIntMap a -> f (PatchIntMap b) Source #
Map an effectful function Int -> a -> f b
over all a
s in the given
(that is, all inserts/updates), producing a PatchIntMap
af (PatchIntMap b)
.
patchIntMapNewElements :: PatchIntMap a -> [a] Source #
Extract all a
s inserted/updated by the given
.PatchIntMap
a
patchIntMapNewElementsMap :: PatchIntMap a -> IntMap a Source #
Convert the given
into an PatchIntMap
a
with all
the inserts/updates in the given patch.IntMap
a
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 Nothing
s
PatchMap | |
|
Instances
FunctorWithIndex k (PatchMap k) Source # | |
Defined in Data.Patch.Map | |
FoldableWithIndex k (PatchMap k) Source # | |
TraversableWithIndex k (PatchMap k) Source # | |
Defined in Data.Patch.Map itraverse :: Applicative f => (k -> a -> f b) -> PatchMap k a -> f (PatchMap k b) # itraversed :: IndexedTraversal k (PatchMap k a) (PatchMap k b) a b # | |
Functor (PatchMap k) Source # |
|
Foldable (PatchMap k) Source # | |
Defined in Data.Patch.Map fold :: 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 # | |
Traversable (PatchMap k) Source # | |
(Eq k, Eq v) => Eq (PatchMap k v) Source # | |
(Ord k, Ord v) => Ord (PatchMap k v) Source # | |
Defined in Data.Patch.Map | |
(Ord k, Read k, Read v) => Read (PatchMap k v) Source # | |
(Show k, Show v) => Show (PatchMap k v) Source # | |
Ord k => Semigroup (PatchMap k v) Source # |
|
Ord k => Monoid (PatchMap k v) Source # | The empty |
Wrapped (PatchMap k v) Source # | |
Ord k => DecidablyEmpty (PatchMap k v) Source # | |
Ord k => Patch (PatchMap k v) Source # | Apply the insertions or deletions to a given |
Defined in Data.Patch.Map type PatchTarget (PatchMap k v) :: Type Source # apply :: PatchMap k v -> PatchTarget (PatchMap k v) -> Maybe (PatchTarget (PatchMap k v)) Source # | |
PatchMap k1 v1 ~ t => Rewrapped (PatchMap k2 v2) t Source # | |
Defined in Data.Patch.Map | |
type Unwrapped (PatchMap k v) Source # | |
Defined in Data.Patch.Map | |
type PatchTarget (PatchMap k v) Source # | |
Defined in Data.Patch.Map |
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
,
while deletions are represented as ComposeMaybe
(Just value)
.ComposeMaybe
Nothing
PatchDMap | |
|
Instances
GCompare k2 => Semigroup (PatchDMap k2 v) Source # | |
GCompare k2 => Monoid (PatchDMap k2 v) Source # | |
GCompare k2 => DecidablyEmpty (PatchDMap k2 v) Source # | |
GCompare k2 => Patch (PatchDMap k2 v) Source # | Apply the insertions or deletions to a given |
Defined in Data.Patch.DMap type PatchTarget (PatchDMap k2 v) :: Type Source # apply :: PatchDMap k2 v -> PatchTarget (PatchDMap k2 v) -> Maybe (PatchTarget (PatchDMap k2 v)) Source # | |
type PatchTarget (PatchDMap k2 v) Source # | |
Defined in Data.Patch.DMap |
mapPatchDMap :: (forall a. v a -> v' a) -> PatchDMap k v -> PatchDMap k v' Source #
traversePatchDMap :: Applicative f => (forall a. v a -> f (v' a)) -> PatchDMap k v -> f (PatchDMap k v') Source #
traversePatchDMapWithKey :: Applicative m => (forall a. k a -> v a -> m (v' a)) -> PatchDMap k v -> m (PatchDMap k v') Source #
const2PatchDMapWith :: forall k v v' a. (v -> v' a) -> PatchMap k v -> PatchDMap (Const2 k a) v' Source #
const2IntPatchDMapWith :: forall v f a. (v -> f a) -> PatchIntMap v -> PatchDMap (Const2 Key a) f Source #
Convert a
into a PatchIntMap
v
using a function PatchDMap
(Const2
Int a) v'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
unsafePatchMapWithMove :: Map k (NodeInfo k v) -> PatchMapWithMove k v Source #
Wrap a
representing patch changes into a Map
k (NodeInfo k v)
, without checking any invariants.PatchMapWithMove
k v
Warning: when using this function, you must ensure that the invariants of PatchMapWithMove
are preserved; they will not be checked.
patchMapWithMoveNewElements :: PatchMapWithMove k v -> [v] Source #
Returns all the new elements that will be added to the Map
.
patchMapWithMoveNewElementsMap :: PatchMapWithMove k v -> Map k v Source #
Return a
with all the inserts/updates from the given Map
k v
.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
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
into PatchDMapWithMove
k v
.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
into PatchDMapWithMove
k vm (
.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
and applying a given weakening function Some
kv a -> v'
to
values.
patchDMapWithMoveToPatchMapWithMoveWith :: forall k v v' a. (v a -> v') -> PatchDMapWithMove (Const2 k a) v -> PatchMapWithMove k v' Source #
Weaken a
to a PatchDMapWithMove
(Const2 k a) v
. Weaken is in scare quotes because the PatchMapWithMove
k v'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
into a PatchMapWithMove
k v'PatchDMapWithMove (
; that is, turn a non-dependently-typed patch into a dependently typed
one but which always has a constant key type represented by Const2
k a)Const2
. Apply the given function to each v
to produce a v' a
.
Completemented by patchDMapWithMoveToPatchMapWithMoveWith