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 :: *
- 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 (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
- unPatchMapWithMove :: PatchMapWithMove k v -> Map k (NodeInfo 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 Reflex.Patch type PatchTarget (AdditivePatch p) :: * Source # apply :: AdditivePatch p -> PatchTarget (AdditivePatch p) -> Maybe (PatchTarget (AdditivePatch p)) Source # | |
type PatchTarget (AdditivePatch p) Source # | |
Defined in Reflex.Patch |
class Semigroup q => Additive q Source #
Instances
Additive SelectedCount Source # | |
Defined in Reflex.Query.Class | |
(Ord k, Additive q) => Additive (MonoidalMap k q) Source # | |
Defined in Reflex.Patch |
class (Semigroup q, Monoid q) => Group q where Source #
Instances
Group SelectedCount Source # | |
Defined in Reflex.Query.Class negateG :: SelectedCount -> SelectedCount Source # (~~) :: SelectedCount -> SelectedCount -> SelectedCount Source # | |
(Ord k, Group q) => Group (MonoidalMap k q) Source # | |
Defined in Reflex.Patch negateG :: MonoidalMap k q -> MonoidalMap k q Source # (~~) :: MonoidalMap k q -> MonoidalMap k q -> MonoidalMap k q 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 (IntMap (Maybe a)) |
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
Functor (PatchMap k) Source # |
|
(Eq k, Eq v) => Eq (PatchMap k v) Source # | |
(Ord k, Ord v) => Ord (PatchMap k v) Source # | |
Defined in Reflex.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 |
Ord k => Patch (PatchMap k v) Source # | Apply the insertions or deletions to a given |
Defined in Reflex.Patch.Map type PatchTarget (PatchMap k v) :: * Source # apply :: PatchMap k v -> PatchTarget (PatchMap k v) -> Maybe (PatchTarget (PatchMap k v)) Source # | |
type PatchTarget (PatchMap k v) Source # | |
Defined in Reflex.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 => Patch (PatchDMap k2 v) Source # | Apply the insertions or deletions to a given |
Defined in Reflex.Patch.DMap type PatchTarget (PatchDMap k2 v) :: * Source # apply :: PatchDMap k2 v -> PatchTarget (PatchDMap k2 v) -> Maybe (PatchTarget (PatchDMap k2 v)) Source # | |
type PatchTarget (PatchDMap k2 v) Source # | |
Defined in Reflex.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 DMap 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
unPatchMapWithMove :: PatchMapWithMove k v -> Map k (NodeInfo k v) Source #
Extract the internal representation of the PatchMapWithMove
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