Copyright | (c) 2016 Sentenai |
---|---|
License | Apache |
Maintainer | Tim McGilchrist <timmcgil@gmail.com>, Mark Hibberd <mark@hibberd.id.au> |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Haskell-side view of CRDT
Synopsis
- data DataType
- newtype Counter = Counter Count
- type Count = Int64
- data CounterOp = CounterInc !Count
- newtype Set = Set (Set ByteString)
- data SetOp
- newtype Map = Map MapContent
- type MapContent = Map MapField MapEntry
- data MapField = MapField MapEntryTag ByteString
- data MapEntry
- = MapCounter !Counter
- | MapSet !Set
- | MapRegister !Register
- | MapFlag !Flag
- | MapMap !Map
- xlookup :: MapPath -> MapEntryTag -> Map -> Maybe MapEntry
- data MapOp
- newtype MapPath = MapPath (NonEmpty ByteString)
- data MapValueOp
- mapUpdate :: IsMapOp o => MapPath -> o -> MapOp
- (-/) :: ByteString -> MapPath -> MapPath
- newtype Register = Register ByteString
- data RegisterOp = RegisterSet !ByteString
- newtype Flag = Flag Bool
- data FlagOp = FlagSet !Bool
- data NonEmpty a = a :| [a]
- mapEntryTag :: MapValueOp -> MapEntryTag
- setFromList :: [ByteString] -> Set
- data MapEntryTag
Types
CRDT ADT.
get
operations return value of this type
Instances
Eq DataType Source # | |
Show DataType Source # | |
Generic DataType Source # | |
NFData DataType Source # | |
Defined in Network.Riak.CRDT.Types | |
type Rep DataType Source # | |
Defined in Network.Riak.CRDT.Types type Rep DataType = D1 ('MetaData "DataType" "Network.Riak.CRDT.Types" "riak-1.2.0.0-CYLrRp5TJSeH9YOHpDuG7W" 'False) (C1 ('MetaCons "DTCounter" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Counter)) :+: (C1 ('MetaCons "DTSet" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Set)) :+: C1 ('MetaCons "DTMap" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Map)))) |
Counters
CRDT Counter hold a integer Count
>>>
Counter 42
Instances
Eq Counter Source # | |
Num Counter Source # | |
Ord Counter Source # | |
Show Counter Source # | |
Generic Counter Source # | |
Semigroup Counter Source # | |
Monoid Counter Source # | |
Default Counter Source # | |
Defined in Network.Riak.CRDT.Types | |
NFData Counter Source # | |
Defined in Network.Riak.CRDT.Types | |
CRDT Counter CounterOp Source # | |
Defined in Network.Riak.CRDT modify :: CounterOp -> Counter -> Counter Source # sendModify :: Connection -> BucketType -> Bucket -> Key -> [CounterOp] -> IO () Source # | |
type Rep Counter Source # | |
Defined in Network.Riak.CRDT.Types |
Modification
Counters can be incremented/decremented
>>>
CounterInc 1
Instances
Eq CounterOp Source # | |
Show CounterOp Source # | |
Semigroup CounterOp Source # | |
Monoid CounterOp Source # | |
CRDT Counter CounterOp Source # | |
Defined in Network.Riak.CRDT modify :: CounterOp -> Counter -> Counter Source # sendModify :: Connection -> BucketType -> Bucket -> Key -> [CounterOp] -> IO () Source # |
Sets
CRDT Set is a Data.Set
>>>
Set (Data.Set.fromList ["foo","bar"])
Set (Set ByteString) |
Instances
Eq Set Source # | |
Ord Set Source # | |
Show Set Source # | |
Generic Set Source # | |
Semigroup Set Source # | |
Monoid Set Source # | |
Default Set Source # | |
Defined in Network.Riak.CRDT.Types | |
NFData Set Source # | |
Defined in Network.Riak.CRDT.Types | |
CRDT Set SetOp Source # | |
Defined in Network.Riak.CRDT modify :: SetOp -> Set -> Set Source # sendModify :: Connection -> BucketType -> Bucket -> Key -> [SetOp] -> IO () Source # | |
type Rep Set Source # | |
Defined in Network.Riak.CRDT.Types type Rep Set = D1 ('MetaData "Set" "Network.Riak.CRDT.Types" "riak-1.2.0.0-CYLrRp5TJSeH9YOHpDuG7W" 'True) (C1 ('MetaCons "Set" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Set ByteString)))) |
Modification
CRDT Set operations
SetAdd ByteString | add element to the set
|
SetRemove ByteString | remove element from the set
|
Maps
CRDT Map is a Data.Map indexed by MapField
and holding
MapEntry
.
Maps are specials in a way that they can additionally
hold Flag
s, Register
s, and most importantly, other Map
s.
Instances
Eq Map Source # | |
Show Map Source # | |
Generic Map Source # | |
Default Map Source # | |
Defined in Network.Riak.CRDT.Types | |
NFData Map Source # | |
Defined in Network.Riak.CRDT.Types | |
CRDT Map MapOp Source # | |
Defined in Network.Riak.CRDT modify :: MapOp -> Map -> Map Source # sendModify :: Connection -> BucketType -> Bucket -> Key -> [MapOp] -> IO () Source # | |
type Rep Map Source # | |
Defined in Network.Riak.CRDT.Types type Rep Map = D1 ('MetaData "Map" "Network.Riak.CRDT.Types" "riak-1.2.0.0-CYLrRp5TJSeH9YOHpDuG7W" 'True) (C1 ('MetaCons "Map" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 MapContent))) |
CRDT Map is indexed by MapField, which is a name tagged by a type (there may be different entries with the same name, but different types)
Instances
Eq MapField Source # | |
Ord MapField Source # | |
Defined in Network.Riak.CRDT.Types | |
Show MapField Source # | |
Generic MapField Source # | |
NFData MapField Source # | |
Defined in Network.Riak.CRDT.Types | |
type Rep MapField Source # | |
Defined in Network.Riak.CRDT.Types type Rep MapField = D1 ('MetaData "MapField" "Network.Riak.CRDT.Types" "riak-1.2.0.0-CYLrRp5TJSeH9YOHpDuG7W" 'False) (C1 ('MetaCons "MapField" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 MapEntryTag) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) |
CRDT Map holds values of type MapEntry
Instances
Inspection
xlookup :: MapPath -> MapEntryTag -> Map -> Maybe MapEntry Source #
Lookup a value of a given MapEntryTag
type on a given MapPath
inside a map
>>>
lookup ("a" -/ "b") MapFlagTag $ { "a"/Map: { "b"/Flag: Flag False } } -- pseudo
Just (MapFlag (Flag False))
Modification
map operations
It's easier to use mapUpdate
:
>>>
"x" -/ "y" -/ "z" `mapUpdate` SetAdd "elem"
MapUpdate (MapPath ("x" :| ["y","z"])) (MapCounterOp (CounterInc 1))
MapRemove MapField | remove value in map |
MapUpdate MapPath MapValueOp | update value on path by operation |
Selector (“xpath”) inside Map
data MapValueOp Source #
Operations on map values
Instances
Eq MapValueOp Source # | |
Defined in Network.Riak.CRDT.Types (==) :: MapValueOp -> MapValueOp -> Bool # (/=) :: MapValueOp -> MapValueOp -> Bool # | |
Show MapValueOp Source # | |
Defined in Network.Riak.CRDT.Types showsPrec :: Int -> MapValueOp -> ShowS # show :: MapValueOp -> String # showList :: [MapValueOp] -> ShowS # |
Registers
Registers can only be held as a Map
element.
Register holds a ByteString
.
Instances
Eq Register Source # | |
Show Register Source # | |
Generic Register Source # | |
Semigroup Register Source # | |
Monoid Register Source # | Last-wins monoid for |
Default Register Source # | |
Defined in Network.Riak.CRDT.Types | |
NFData Register Source # | |
Defined in Network.Riak.CRDT.Types | |
type Rep Register Source # | |
Defined in Network.Riak.CRDT.Types type Rep Register = D1 ('MetaData "Register" "Network.Riak.CRDT.Types" "riak-1.2.0.0-CYLrRp5TJSeH9YOHpDuG7W" 'True) (C1 ('MetaCons "Register" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) |
Modification
data RegisterOp Source #
Registers can be set to a value
>>>
RegisterSet "foo"
Instances
Eq RegisterOp Source # | |
Defined in Network.Riak.CRDT.Types (==) :: RegisterOp -> RegisterOp -> Bool # (/=) :: RegisterOp -> RegisterOp -> Bool # | |
Show RegisterOp Source # | |
Defined in Network.Riak.CRDT.Types showsPrec :: Int -> RegisterOp -> ShowS # show :: RegisterOp -> String # showList :: [RegisterOp] -> ShowS # |
Flags
Instances
Eq Flag Source # | |
Ord Flag Source # | |
Show Flag Source # | |
Generic Flag Source # | |
Semigroup Flag Source # | Last-wins semigroup for |
Monoid Flag Source # | Last-wins monoid for |
Default Flag Source # | |
Defined in Network.Riak.CRDT.Types | |
NFData Flag Source # | |
Defined in Network.Riak.CRDT.Types | |
type Rep Flag Source # | |
Defined in Network.Riak.CRDT.Types |
Modification
Flags can be enabled / disabled
>>>
FlagSet True
Misc
Non-empty (and non-strict) list type.
Since: base-4.9.0.0
a :| [a] infixr 5 |
Instances
Monad NonEmpty | Since: base-4.9.0.0 |
Functor NonEmpty | Since: base-4.9.0.0 |
Applicative NonEmpty | Since: base-4.9.0.0 |
Foldable NonEmpty | Since: base-4.9.0.0 |
Defined in Data.Foldable fold :: Monoid m => NonEmpty m -> m # foldMap :: Monoid m => (a -> m) -> NonEmpty a -> m # foldMap' :: Monoid m => (a -> m) -> NonEmpty a -> m # foldr :: (a -> b -> b) -> b -> NonEmpty a -> b # foldr' :: (a -> b -> b) -> b -> NonEmpty a -> b # foldl :: (b -> a -> b) -> b -> NonEmpty a -> b # foldl' :: (b -> a -> b) -> b -> NonEmpty a -> b # foldr1 :: (a -> a -> a) -> NonEmpty a -> a # foldl1 :: (a -> a -> a) -> NonEmpty a -> a # elem :: Eq a => a -> NonEmpty a -> Bool # maximum :: Ord a => NonEmpty a -> a # minimum :: Ord a => NonEmpty a -> a # | |
Traversable NonEmpty | Since: base-4.9.0.0 |
ToJSON1 NonEmpty | |
Defined in Data.Aeson.Types.ToJSON liftToJSON :: (a -> Value) -> ([a] -> Value) -> NonEmpty a -> Value # liftToJSONList :: (a -> Value) -> ([a] -> Value) -> [NonEmpty a] -> Value # liftToEncoding :: (a -> Encoding) -> ([a] -> Encoding) -> NonEmpty a -> Encoding # liftToEncodingList :: (a -> Encoding) -> ([a] -> Encoding) -> [NonEmpty a] -> Encoding # | |
FromJSON1 NonEmpty | |
Eq1 NonEmpty | Since: base-4.10.0.0 |
Ord1 NonEmpty | Since: base-4.10.0.0 |
Defined in Data.Functor.Classes | |
Read1 NonEmpty | Since: base-4.10.0.0 |
Defined in Data.Functor.Classes | |
Show1 NonEmpty | Since: base-4.10.0.0 |
NFData1 NonEmpty | Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
Hashable1 NonEmpty | Since: hashable-1.3.1.0 |
Defined in Data.Hashable.Class | |
Lift a => Lift (NonEmpty a :: Type) | Since: template-haskell-2.15.0.0 |
IsList (NonEmpty a) | Since: base-4.9.0.0 |
Eq a => Eq (NonEmpty a) | Since: base-4.9.0.0 |
Data a => Data (NonEmpty a) | Since: base-4.9.0.0 |
Defined in Data.Data gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> NonEmpty a -> c (NonEmpty a) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (NonEmpty a) # toConstr :: NonEmpty a -> Constr # dataTypeOf :: NonEmpty a -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (NonEmpty a)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (NonEmpty a)) # gmapT :: (forall b. Data b => b -> b) -> NonEmpty a -> NonEmpty a # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> NonEmpty a -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> NonEmpty a -> r # gmapQ :: (forall d. Data d => d -> u) -> NonEmpty a -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> NonEmpty a -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> NonEmpty a -> m (NonEmpty a) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> NonEmpty a -> m (NonEmpty a) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> NonEmpty a -> m (NonEmpty a) # | |
Ord a => Ord (NonEmpty a) | Since: base-4.9.0.0 |
Read a => Read (NonEmpty a) | Since: base-4.11.0.0 |
Show a => Show (NonEmpty a) | Since: base-4.11.0.0 |
Generic (NonEmpty a) | Since: base-4.6.0.0 |
Semigroup (NonEmpty a) | Since: base-4.9.0.0 |
Hashable a => Hashable (NonEmpty a) | |
Defined in Data.Hashable.Class | |
ToJSON a => ToJSON (NonEmpty a) | |
Defined in Data.Aeson.Types.ToJSON | |
FromJSON a => FromJSON (NonEmpty a) | |
NFData a => NFData (NonEmpty a) | Since: deepseq-1.4.2.0 |
Defined in Control.DeepSeq | |
Generic1 NonEmpty | Since: base-4.6.0.0 |
type Rep (NonEmpty a) | |
Defined in GHC.Generics type Rep (NonEmpty a) = D1 ('MetaData "NonEmpty" "GHC.Base" "base" 'False) (C1 ('MetaCons ":|" ('InfixI 'LeftAssociative 9) 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [a]))) | |
type Item (NonEmpty a) | |
type Rep1 NonEmpty | |
Defined in GHC.Generics type Rep1 NonEmpty = D1 ('MetaData "NonEmpty" "GHC.Base" "base" 'False) (C1 ('MetaCons ":|" ('InfixI 'LeftAssociative 9) 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) Par1 :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec1 []))) |
mapEntryTag :: MapValueOp -> MapEntryTag Source #
setFromList :: [ByteString] -> Set Source #
data MapEntryTag Source #