Safe Haskell | None |
---|
Internal functions; typically unneeded by users.
One common case is defining certain Incremental instances. Sometimes
instead of deriving an Incremental instance you want to always send new data
if it has changed. This is easily supported with the DPrim
type and
helper functions:
import Data.Increments.Internal instance Incremental Foo where type Increment Foo = DPrim Foo changes = iprimDiff applyChanges = iprimApply
This is especially useful with large types that do not change often, when attempting to calculate the difference may be very expensive.
- class Incremental a where
- type Increment a :: *
- changes :: a -> a -> Increment a
- applyChanges :: a -> Increment a -> a
- class Changed a where
- type IncrementalCnstr a = (Incremental a, Changed (Increment a))
- data DPrim a
- = DPrim a
- | DPrim_NoChange
- iprimDiff :: Eq a => a -> a -> DPrim a
- iprimApply :: a -> DPrim a -> a
Documentation
class Incremental a whereSource
Calculate differences between data structures.
changes :: a -> a -> Increment aSource
generate the changes between the previous
and current
data
applyChanges :: a -> Increment a -> aSource
Apply a changes to a value
Determine if a Increment representation contains a real change. Unchanging changes may be omitted.
type IncrementalCnstr a = (Incremental a, Changed (Increment a))Source
A useful type constraint synonym for writing instances
helpers for creating instances for primitive-ish types
iprimApply :: a -> DPrim a -> aSource