Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Data.Clock.IntervalTree
Contents
Description
An interval tree clock implementation as per Interval Tree Clocks: A Logical Clock for Dynamic Systems. Paper by Almeida, Paulo & Baquero, Carlos & Fonte, Victor. This implementation by Arne Winter.
Synopsis
- data Stamp = Stamp ITCId ITCEvent
- data ITCId
- data ITCEvent
- seed :: Stamp
- fork :: Stamp -> (Stamp, Stamp)
- join :: Stamp -> Stamp -> Stamp
- peek :: Stamp -> Stamp
- event :: Stamp -> Stamp
- happenedBefore :: Stamp -> Stamp -> Bool
- data StampComparison
- = Before
- | After
- | Concurrent
- stampCompare :: Stamp -> Stamp -> StampComparison
Types
Instances
Eq Stamp Source # | |
Show Stamp Source # | |
Generic Stamp Source # | |
type Rep Stamp Source # | |
Defined in Data.Clock.IntervalTree type Rep Stamp = D1 ('MetaData "Stamp" "Data.Clock.IntervalTree" "interval-tree-clock-0.2.0.0-inplace" 'False) (C1 ('MetaCons "Stamp" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ITCId) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ITCEvent))) |
Constructors
ITCIdBranch ITCId ITCId | |
ITCIdOff | |
ITCIdOn |
Instances
Eq ITCId Source # | |
Show ITCId Source # | |
Generic ITCId Source # | |
type Rep ITCId Source # | |
Defined in Data.Clock.IntervalTree type Rep ITCId = D1 ('MetaData "ITCId" "Data.Clock.IntervalTree" "interval-tree-clock-0.2.0.0-inplace" 'False) (C1 ('MetaCons "ITCIdBranch" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ITCId) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ITCId)) :+: (C1 ('MetaCons "ITCIdOff" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ITCIdOn" 'PrefixI 'False) (U1 :: Type -> Type))) |
Constructors
ITCEventBranch !Integer ITCEvent ITCEvent | |
ITCEventLeaf !Integer |
Instances
Eq ITCEvent Source # | |
Show ITCEvent Source # | |
Generic ITCEvent Source # | |
type Rep ITCEvent Source # | |
Defined in Data.Clock.IntervalTree type Rep ITCEvent = D1 ('MetaData "ITCEvent" "Data.Clock.IntervalTree" "interval-tree-clock-0.2.0.0-inplace" 'False) (C1 ('MetaCons "ITCEventBranch" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Integer) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ITCEvent) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ITCEvent))) :+: C1 ('MetaCons "ITCEventLeaf" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 Integer))) |
Seed
Operations
fork :: Stamp -> (Stamp, Stamp) Source #
use to register new peers. one stamp must be consecutively owned be the forking peer. the other stamp owned by host.
peek :: Stamp -> Stamp Source #
Anonymizes this stamp. Useful when sending messages or logging debug stamps.
Comparison
happenedBefore :: Stamp -> Stamp -> Bool Source #
the `happened before` relation for two stamps. (Note that I am unsure whether this is really the same relation as described by Lamport). Use this to examine causality of stamps.
data StampComparison Source #
Constructors
Before | A happened before B. |
After | A happened after B. |
Concurrent | A happened concurrent to B in logical time. |
Instances
Eq StampComparison Source # | |
Defined in Data.Clock.IntervalTree Methods (==) :: StampComparison -> StampComparison -> Bool # (/=) :: StampComparison -> StampComparison -> Bool # | |
Show StampComparison Source # | |
Defined in Data.Clock.IntervalTree Methods showsPrec :: Int -> StampComparison -> ShowS # show :: StampComparison -> String # showList :: [StampComparison] -> ShowS # |
stampCompare :: Stamp -> Stamp -> StampComparison Source #
Compare two stamps. Note that stamp is not an instance of Ord because a <= b and b <= a does not imply a = b: rather that a happened concurrent to b per logical time.