hkd-delta-0.0.1: Definition of "Delta structures" for higher kinded data.

Safe HaskellSafe
LanguageHaskell2010

HKD.Delta.Class

Synopsis

Documentation

class HasDelta a where Source #

Types which can be "diffed" and "patched".

Minimal complete definition

Nothing

Associated Types

type DeltaOf a Source #

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.

Methods

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
HasDelta Bool Source # 
Instance details

Defined in HKD.Delta.Class

Associated Types

type DeltaOf Bool :: Type Source #

type DeltaAlways Bool :: Bool Source #

HasDelta Char Source # 
Instance details

Defined in HKD.Delta.Class

Associated Types

type DeltaOf Char :: Type Source #

type DeltaAlways Char :: Bool Source #

HasDelta Double Source # 
Instance details

Defined in HKD.Delta.Class

Associated Types

type DeltaOf Double :: Type Source #

type DeltaAlways Double :: Bool Source #

HasDelta Float Source # 
Instance details

Defined in HKD.Delta.Class

Associated Types

type DeltaOf Float :: Type Source #

type DeltaAlways Float :: Bool Source #

HasDelta Int Source # 
Instance details

Defined in HKD.Delta.Class

Associated Types

type DeltaOf Int :: Type Source #

type DeltaAlways Int :: Bool Source #

HasDelta Integer Source # 
Instance details

Defined in HKD.Delta.Class

Associated Types

type DeltaOf Integer :: Type Source #

type DeltaAlways Integer :: Bool Source #

HasDelta () Source #

Only never Change

Instance details

Defined in HKD.Delta.Class

Associated Types

type DeltaOf () :: Type Source #

type DeltaAlways () :: Bool Source #

Methods

calcDelta :: () -> () -> DeltaReturn () Source #

applyDelta :: () -> DeltaReturn () -> () Source #

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.