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

Safe HaskellSafe
LanguageHaskell2010

Data.Patch.Class

Description

The interface for types which represent changes made to other types

Synopsis

Documentation

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
Patch (Identity a) Source #

Identity can be used as a Patch that always fully replaces the value

Instance details

Defined in Data.Patch.Class

Associated Types

type PatchTarget (Identity a) :: Type Source #

Patch (PatchIntMap a) Source #

Apply the insertions or deletions to a given IntMap.

Instance details

Defined in Data.Patch.IntMap

Associated Types

type PatchTarget (PatchIntMap a) :: Type Source #

Additive p => Patch (AdditivePatch p) Source # 
Instance details

Defined in Data.Patch

Associated Types

type PatchTarget (AdditivePatch p) :: Type Source #

Patch (Proxy a) Source #

Proxy can be used as a Patch that does nothing.

Instance details

Defined in Data.Patch.Class

Associated Types

type PatchTarget (Proxy a) :: Type Source #

Methods

apply :: 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 details

Defined in Data.Patch.Map

Associated Types

type PatchTarget (PatchMap k v) :: Type Source #

Methods

apply :: 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 details

Defined in Data.Patch.MapWithMove

Associated Types

type PatchTarget (PatchMapWithMove k v) :: Type Source #

(Ord k, Patch p) => Patch (PatchMapWithPatchingMove k p) Source #

Apply the insertions, deletions, and moves to a given Map

Instance details

Defined in Data.Patch.MapWithPatchingMove

Associated Types

type PatchTarget (PatchMapWithPatchingMove k p) :: Type Source #

GCompare k2 => Patch (PatchDMap k2 v) Source #

Apply the insertions or deletions to a given DMap.

Instance details

Defined in Data.Patch.DMap

Associated Types

type PatchTarget (PatchDMap k2 v) :: Type Source #

Methods

apply :: 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 details

Defined in Data.Patch.DMapWithMove

Associated Types

type PatchTarget (PatchDMapWithMove k2 v) :: Type 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 '(.)'.