crdt-10.3: Conflict-free replicated data types

Safe HaskellNone
LanguageHaskell2010

CRDT.LWW

Contents

Synopsis

Documentation

data LWW a Source #

Last write wins. Assuming timestamp is unique. This type is both CmRDT and CvRDT.

Timestamps are assumed unique, totally ordered, and consistent with causal order; i.e., if assignment 1 happened-before assignment 2, the former’s timestamp is less than the latter’s.

Constructors

LWW 

Fields

Instances
Eq a => Eq (LWW a) Source # 
Instance details

Defined in CRDT.LWW

Methods

(==) :: LWW a -> LWW a -> Bool #

(/=) :: LWW a -> LWW a -> Bool #

Show a => Show (LWW a) Source # 
Instance details

Defined in CRDT.LWW

Methods

showsPrec :: Int -> LWW a -> ShowS #

show :: LWW a -> String #

showList :: [LWW a] -> ShowS #

Eq a => Semigroup (LWW a) Source #

Merge by choosing more recent timestamp.

Instance details

Defined in CRDT.LWW

Methods

(<>) :: LWW a -> LWW a -> LWW a #

sconcat :: NonEmpty (LWW a) -> LWW a #

stimes :: Integral b => b -> LWW a -> LWW a #

Eq a => Semilattice (LWW a) Source #

See CvRDT

Instance details

Defined in CRDT.LWW

Eq a => CmRDT (LWW a) Source # 
Instance details

Defined in CRDT.LWW

Associated Types

type Intent (LWW a) :: * Source #

type Payload (LWW a) :: * Source #

Methods

initial :: Payload (LWW a) Source #

makeOp :: Clock m => Intent (LWW a) -> Payload (LWW a) -> Maybe (m (LWW a)) Source #

apply :: LWW a -> Payload (LWW a) -> Payload (LWW a) Source #

CausalOrd (LWW a) Source # 
Instance details

Defined in CRDT.LWW

Methods

precedes :: LWW a -> LWW a -> Bool Source #

type Intent (LWW a) Source # 
Instance details

Defined in CRDT.LWW

type Intent (LWW a) = a
type Payload (LWW a) Source # 
Instance details

Defined in CRDT.LWW

type Payload (LWW a) = Maybe (LWW a)

CvRDT

initialize :: Clock m => a -> m (LWW a) Source #

Initialize state

assign :: Clock m => a -> LWW a -> m (LWW a) Source #

Change state as CvRDT operation. Current value is ignored, because new timestamp is always greater.

query :: LWW a -> a Source #

Query state

Implementation detail

advanceFromLWW :: Clock m => LWW a -> m () Source #