increments-0.1.0.4: type classes for incremental updates to data

Safe HaskellNone
LanguageHaskell98

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 where Source

Calculate differences between data structures.

Minimal complete definition

Nothing

Associated Types

type Increment a :: * Source

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

class Changed a where Source

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

Methods

didChange :: a -> Bool Source

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) 
type Rep (DPrim a) 

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

iprimApply :: a -> DPrim a -> a Source