Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This is a class for types which represent changes made to other types
Synopsis
- class Patch p where
- type PatchTarget p :: Type
- 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
Documentation
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 :: Type 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 #