ron-rdt-0.7: Replicated Data Types (RON-RDT)

Safe HaskellNone
LanguageHaskell2010

RON.Data

Contents

Description

Typed and untyped RON tools

Synopsis

Documentation

class (Eq a, Monoid a) => Reducible a where Source #

Untyped-reducible types. Untyped means if this type is a container then the types of data contained in it is not considered.

Minimal complete definition

reducibleOpType, stateFromChunk, stateToChunk

Methods

reducibleOpType :: UUID Source #

UUID of the type

stateFromChunk :: [Op] -> a Source #

Load a state from a state chunk

stateToChunk :: a -> StateChunk Source #

Store a state to a state chunk

applyPatches :: a -> Unapplied -> (a, Unapplied) Source #

Merge a state with patches and raw ops

reduceUnappliedPatches :: Unapplied -> Unapplied Source #

Merge patches and raw ops into bigger patches or throw obsolete ops

Instances
Reducible LwwRep Source # 
Instance details

Defined in RON.Data.LWW

Reducible ORSetRep Source # 
Instance details

Defined in RON.Data.ORSet

Reducible RgaRep Source # 
Instance details

Defined in RON.Data.RGA

Reducible VersionVector Source # 
Instance details

Defined in RON.Data.VersionVector

class Replicated a where Source #

Base class for typed encoding

Methods

encoding :: Encoding a Source #

Instances SHOULD implement encoding either as objectEncoding or as payloadEncoding

Instances
Replicated Bool Source # 
Instance details

Defined in RON.Data.Internal

Methods

encoding :: Encoding Bool Source #

Replicated Char Source # 
Instance details

Defined in RON.Data.Internal

Methods

encoding :: Encoding Char Source #

Replicated Int64 Source # 
Instance details

Defined in RON.Data.Internal

Methods

encoding :: Encoding Int64 Source #

Replicated Text Source # 
Instance details

Defined in RON.Data.Internal

Methods

encoding :: Encoding Text Source #

Replicated UUID Source # 
Instance details

Defined in RON.Data.Internal

Methods

encoding :: Encoding UUID Source #

Replicated Day Source # 
Instance details

Defined in RON.Data.Time

Methods

encoding :: Encoding Day Source #

Replicated VersionVector Source # 
Instance details

Defined in RON.Data.VersionVector

Methods

encoding :: Encoding VersionVector Source #

Replicated a => Replicated (Maybe a) Source # 
Instance details

Defined in RON.Data.Internal

Methods

encoding :: Encoding (Maybe a) Source #

Replicated a => Replicated (ORSet a) Source # 
Instance details

Defined in RON.Data.ORSet

Methods

encoding :: Encoding (ORSet a) Source #

Replicated a => Replicated (RGA a) Source # 
Instance details

Defined in RON.Data.RGA

Methods

encoding :: Encoding (RGA a) Source #

class Replicated a => ReplicatedAsObject a where Source #

Instances of this class are encoded as objects. An enclosing object's payload will be filled with this object's id.

Law: encoding == objectEncoding

Methods

objectOpType :: UUID Source #

UUID of the type

newObject :: (ReplicaClock m, MonadState StateFrame m) => a -> m (Object a) Source #

Encode data. Write frame and return id.

getObject :: (MonadE m, MonadObjectState a m) => m a Source #

Decode data

class Replicated a => ReplicatedAsPayload a where Source #

Instances of this class are encoded as payload only.

Law: encoding == payloadEncoding

Methods

toPayload :: a -> [Atom] Source #

Encode data

fromPayload :: MonadE m => [Atom] -> m a Source #

Decode data

Instances
ReplicatedAsPayload Bool Source # 
Instance details

Defined in RON.Data.Internal

Methods

toPayload :: Bool -> [Atom] Source #

fromPayload :: MonadE m => [Atom] -> m Bool Source #

ReplicatedAsPayload Char Source # 
Instance details

Defined in RON.Data.Internal

Methods

toPayload :: Char -> [Atom] Source #

fromPayload :: MonadE m => [Atom] -> m Char Source #

ReplicatedAsPayload Int64 Source # 
Instance details

Defined in RON.Data.Internal

Methods

toPayload :: Int64 -> [Atom] Source #

fromPayload :: MonadE m => [Atom] -> m Int64 Source #

ReplicatedAsPayload Text Source # 
Instance details

Defined in RON.Data.Internal

Methods

toPayload :: Text -> [Atom] Source #

fromPayload :: MonadE m => [Atom] -> m Text Source #

ReplicatedAsPayload UUID Source # 
Instance details

Defined in RON.Data.Internal

Methods

toPayload :: UUID -> [Atom] Source #

fromPayload :: MonadE m => [Atom] -> m UUID Source #

ReplicatedAsPayload Day Source # 
Instance details

Defined in RON.Data.Time

Methods

toPayload :: Day -> [Atom] Source #

fromPayload :: MonadE m => [Atom] -> m Day Source #

ReplicatedAsPayload a => ReplicatedAsPayload (Maybe a) Source # 
Instance details

Defined in RON.Data.Internal

Methods

toPayload :: Maybe a -> [Atom] Source #

fromPayload :: MonadE m => [Atom] -> m (Maybe a) Source #

fromRon :: (MonadE m, Replicated a, MonadState StateFrame m) => [Atom] -> m a Source #

Decode typed data from a payload. The implementation may use other objects in the frame to resolve references. TODO(2019-06-28, cblp) use ReaderT for symmetry with newRon

newRon :: (Replicated a, ReplicaClock m, MonadState StateFrame m) => a -> m [Atom] Source #

Encode typed data to a payload with possible addition objects

objectEncoding :: ReplicatedAsObject a => Encoding a Source #

Standard implementation of Replicated for ReplicatedAsObject types.

payloadEncoding :: ReplicatedAsPayload a => Encoding a Source #

Standard implementation of Replicated for ReplicatedAsPayload types.

reduceObject :: MonadE m => ObjectState a -> ObjectState a -> m (ObjectState a) Source #

Reduce object with frame from another version of the same object.

ObjectState monad

evalObjectState :: Monad m => ObjectState b -> ObjectStateT b m a -> m a Source #

Run ObjectState action

evalObjectState_ :: Monad m => StateT StateFrame m a -> m a Source #

Run ObjectState action, starting with an empty frame

execObjectState :: Monad m => ObjectState b -> ObjectStateT b m a -> m (ObjectState b) Source #

Run ObjectState action

execObjectState_ :: Monad m => StateT StateFrame m a -> m StateFrame Source #

Run ObjectState action, starting with an empty frame

newObjectState :: (ReplicatedAsObject a, ReplicaClock m) => a -> m (ObjectState a) Source #

Create new ObjectState from a value

newObjectStateWith :: Functor m => StateT StateFrame m (Object a) -> m (ObjectState a) Source #

Create new ObjectState with an action

runObjectState :: Functor m => ObjectState b -> ObjectStateT b m a -> m (a, ObjectState b) Source #

Run ObjectState action

runObjectState_ :: StateT StateFrame m a -> m (a, StateFrame) Source #

Run ObjectState action, starting with an empty frame