Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Synopsis
- class HasDelta a where
- type DeltaOf a
- type DeltaAlways a :: Bool
- calcDelta :: a -> a -> DeltaReturn a
- applyDelta :: a -> DeltaReturn a -> a
- type DeltaReturn a = If (DeltaAlways a) (DeltaOf a) (Revise a (DeltaOf a))
- calcDeltaNEQ :: Eq a => a -> a -> Change a
- applyDeltaNEQ :: a -> Change a -> a
Documentation
class HasDelta a where Source #
Types which can be "diffed" and "patched".
Nothing
Specifies how differences in data are measured. This type must be defined.
type DeltaAlways a :: Bool Source #
Used to signal whether or not calcDelta a1 a2
always results in
d :: DeltaOf a
.
This does not need to be defined for Generic
data. If the data
is a single constructor, the delta should always be calculatable,
and the return type is True
.
calcDelta :: a -> a -> DeltaReturn a Source #
Find the difference between two instances of a data.
calcDelta :: HasDeltaVia (DeltaAlways a) a (DeltaReturn a) => a -> a -> DeltaReturn a Source #
Find the difference between two instances of a data.
applyDelta :: a -> DeltaReturn a -> a Source #
Patch a data with difference.
applyDelta :: HasDeltaVia (DeltaAlways a) a (DeltaReturn a) => a -> DeltaReturn a -> a Source #
Patch a data with difference.
Instances
type DeltaReturn a = If (DeltaAlways a) (DeltaOf a) (Revise a (DeltaOf a)) Source #
The result of a delta calculation. For DeltaAlways a = True
,
this is just DeltaOf
. For DeltaAlways a = False
this
resolves to Revise a (DeltaOf a)
calcDeltaNEQ :: Eq a => a -> a -> Change a Source #
Method to calculate delta for simple types.
applyDeltaNEQ :: a -> Change a -> a Source #
Method to apply simple changes. Either replaces with the change or returns the original.