Safe Haskell | None |
---|---|
Language | Haskell98 |
Data.Increments.Internal
Description
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 where Source
Calculate differences between data structures.
Minimal complete definition
Nothing
Methods
changes :: a -> a -> Increment a Source
generate the changes between the previous
and current
data
applyChanges :: a -> Increment a -> a Source
Apply a changes to a value
Instances
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
Constructors
DPrim a | |
DPrim_NoChange |
iprimApply :: a -> DPrim a -> a Source