vector-clock-0.1.1: Vector clocks for versioning message flows

Safe HaskellSafe-Infered

Data.VectorClock

Contents

Synopsis

Vector clock type

data VectorClock a b Source

A vector clock is, conceptually, an associtive list sorted by the value of the key, where each key appears only once.

Instances

(Eq a, Eq b) => Eq (VectorClock a b) 
(Show a, Show b) => Show (VectorClock a b) 
(Binary a, Binary b) => Binary (VectorClock a b) 

Construction

empty :: VectorClock a bSource

The empty vector clock.

singleton :: a -> b -> VectorClock a bSource

A vector clock with a single element.

fromList :: Ord a => [(a, b)] -> VectorClock a bSource

Insert each entry in the list one at a time.

Query

null :: VectorClock a b -> BoolSource

Is the vector clock empty?

size :: VectorClock a b -> IntSource

The number of entries in the vector clock.

member :: Ord a => a -> VectorClock a b -> BoolSource

Is the given key a key in an entry of the vector clock?

lookup :: Ord a => a -> VectorClock a b -> Maybe bSource

Lookup the value for a key in the vector clock.

Insertion

insert :: Ord a => a -> b -> VectorClock a b -> VectorClock a bSource

Insert or replace the entry for a key.

Deletion

delete :: Ord a => a -> VectorClock a b -> VectorClock a bSource

Delete an entry from the vector clock. If the requested entry does not exist, does nothing.

Merges

combine :: (Ord a, Ord b) => (a -> Maybe b -> Maybe b -> Maybe b) -> VectorClock a b -> VectorClock a b -> VectorClock a bSource

Combine two vector clocks entry-by-entry.

max :: (Ord a, Ord b) => VectorClock a b -> VectorClock a b -> VectorClock a bSource

The maximum of the two vector clocks.

Relations

data Relation Source

The relations two vector clocks may find themselves in.

Constructors

Causes 
CausedBy 
Concurrent 

Instances

relation :: (Ord a, Ord b) => VectorClock a b -> VectorClock a b -> RelationSource

The relation between the two vector clocks.

Debugging

valid :: (Ord a, Ord b) => VectorClock a b -> BoolSource

Check whether the vector clock is valid or not.