-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Interval Tree Clocks -- -- A haskell Implementation of the interval tree clock as described in -- the paper Interval Tree Clocks: A Logical Clock for Dynamic Systems. -- -- Light on dependencies! -- -- Interval Tree Clocks serve as an alternative to vector clocks, in that -- clock-carriers may join or enter the system after clock -- initialization. Therefore it is not required to know beforehand how -- many actors are carrying clocks in a distributed system. -- -- This is the first package i'm publishing, please don't hesitate to -- report issues you encounter. Also I did not yet come to use this in -- production myself. -- -- Thoroughly tested, with both quickcheck and visual debugging in -- conformance to the paper. -- -- The paper this library is based on is @Almeida, Paulo & Baquero, -- Carlos & Fonte, Victor. (2008). Interval Tree Clocks: A Logical -- Clock for Dynamic Systems. 5401. 259-274. -- 10.1007/978-3-540-92221-6_18. @package interval-tree-clock @version 0.1.0.2 -- | 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. module Data.Clock.IntervalTree data Stamp Stamp :: ITCId -> ITCEvent -> Stamp data ITCId ITCIdBranch :: ITCId -> ITCId -> ITCId ITCId :: !Bool -> ITCId data ITCEvent ITCEventBranch :: !Integer -> ITCEvent -> ITCEvent -> ITCEvent ITCEventLeaf :: !Integer -> ITCEvent -- | The seed stamp. The first peer is to use this, then fork others. seed :: Stamp -- | use to register new peers. one stamp must be consecutively owned be -- the forking peer. the other stamp owned by host. fork :: Stamp -> (Stamp, Stamp) -- | inverse of fork. s = uncurry join (fork s) Note that the internal call -- to sumId may be partial, if the ITC Stamp was constructed -- through direct constructor usage. Using only fork and -- join as the safe API to create stamps will not lead to this -- inconsistency. join :: Stamp -> Stamp -> Stamp -- | Anonymizes this stamp. Useful when sending messages or logging debug -- stamps. peek :: Stamp -> Stamp -- | when something happened on this peer. use the new stamp afterwards. event :: Stamp -> Stamp -- | 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. happenedBefore :: Stamp -> Stamp -> Bool data StampComparison -- | A happened before B. Before :: StampComparison -- | A happened after B. After :: StampComparison -- | A happened concurrent to B in logical time. Concurrent :: StampComparison -- | 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. stampCompare :: Stamp -> Stamp -> StampComparison instance GHC.Generics.Generic Data.Clock.IntervalTree.ITCId instance GHC.Show.Show Data.Clock.IntervalTree.ITCId instance GHC.Classes.Eq Data.Clock.IntervalTree.ITCId instance GHC.Generics.Generic Data.Clock.IntervalTree.ITCEvent instance GHC.Show.Show Data.Clock.IntervalTree.ITCEvent instance GHC.Classes.Eq Data.Clock.IntervalTree.ITCEvent instance GHC.Generics.Generic Data.Clock.IntervalTree.Stamp instance GHC.Show.Show Data.Clock.IntervalTree.Stamp instance GHC.Classes.Eq Data.Clock.IntervalTree.Stamp instance GHC.Show.Show Data.Clock.IntervalTree.StampComparison instance GHC.Classes.Eq Data.Clock.IntervalTree.StampComparison instance GHC.Classes.Ord Data.Clock.IntervalTree.Cost instance GHC.Classes.Eq Data.Clock.IntervalTree.Cost module Data.Clock.IntervalTree.Format -- | pretty print a stamp, mathematical notation like in the original -- paper. fmtStamp :: Stamp -> String -- | prints a stamp as a tikz picture for latex usage. This mostly aided me -- in visual debugging. fmtStampTikz :: Stamp -> String