increments-0.1.0.2: type classes for incremental updates to data

Safe HaskellNone

Data.Increments.Internal

Contents

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.

Synopsis

Documentation

class Incremental a whereSource

Calculate differences between data structures.

Associated Types

type Increment a :: *Source

Methods

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

class Changed a whereSource

Determine if a Increment representation contains a real change. Unchanging changes may be omitted.

Methods

didChange :: a -> BoolSource

Instances

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

data DPrim a Source

Constructors

DPrim a 
DPrim_NoChange 

Instances

Eq a => Eq (DPrim a) 
Show a => Show (DPrim a) 
Generic (DPrim a) 
Monoid (DPrim a) 
Beamable a => Beamable (DPrim a) 
Changed (DPrim a) 

iprimDiff :: Eq a => a -> a -> DPrim aSource

iprimApply :: a -> DPrim a -> aSource