Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data CalendarTime = CalendarTime {}
- data CalendarEvent = CalendarEvent !CalendarTime !ReplicaId
- data EpochEvent = EpochEvent !EpochTime !ReplicaId
- type EpochTime = Word60
- data Event = Event !LocalTime !ReplicaId
- data LocalTime
- data Naming
- class Monad m => ReplicaClock m where
- data ReplicaId = ReplicaId !Naming !Word60
- advanceToUuid :: ReplicaClock clock => UUID -> clock ()
- applicationSpecific :: Word64 -> ReplicaId
- decodeEvent :: UUID -> Event
- encodeEvent :: Event -> UUID
- fromCalendarEvent :: CalendarEvent -> Event
- fromEpochEvent :: EpochEvent -> Event
- getEvent :: (HasCallStack, ReplicaClock m) => m EpochEvent
- getEventUuid :: ReplicaClock m => m UUID
- getEventUuids :: ReplicaClock m => Word60 -> m [UUID]
- mkCalendarDate :: (Word16, Word16, Word8) -> Maybe CalendarTime
- mkCalendarDateTime :: (Word16, Word16, Word8) -> (Word8, Word8, Word8) -> Maybe CalendarTime
- mkCalendarDateTimeNano :: (Word16, Word16, Word8) -> (Word8, Word8, Word8) -> Word32 -> Maybe CalendarTime
- toEpochEvent :: Event -> Maybe EpochEvent
Documentation
data CalendarTime Source #
Calendar format. See https://github.com/gritzko/ron/issues/19. Year range is 2010—2350. Precision is 100 ns.
Instances
Eq CalendarTime Source # | |
Defined in RON.Event (==) :: CalendarTime -> CalendarTime -> Bool # (/=) :: CalendarTime -> CalendarTime -> Bool # | |
Ord CalendarTime Source # | |
Defined in RON.Event compare :: CalendarTime -> CalendarTime -> Ordering # (<) :: CalendarTime -> CalendarTime -> Bool # (<=) :: CalendarTime -> CalendarTime -> Bool # (>) :: CalendarTime -> CalendarTime -> Bool # (>=) :: CalendarTime -> CalendarTime -> Bool # max :: CalendarTime -> CalendarTime -> CalendarTime # min :: CalendarTime -> CalendarTime -> CalendarTime # | |
Show CalendarTime Source # | |
Defined in RON.Event showsPrec :: Int -> CalendarTime -> ShowS # show :: CalendarTime -> String # showList :: [CalendarTime] -> ShowS # |
data CalendarEvent Source #
Calendar-based Lamport time event, specific case of Event
.
Instances
Eq CalendarEvent Source # | |
Defined in RON.Event (==) :: CalendarEvent -> CalendarEvent -> Bool # (/=) :: CalendarEvent -> CalendarEvent -> Bool # | |
Ord CalendarEvent Source # | |
Defined in RON.Event compare :: CalendarEvent -> CalendarEvent -> Ordering # (<) :: CalendarEvent -> CalendarEvent -> Bool # (<=) :: CalendarEvent -> CalendarEvent -> Bool # (>) :: CalendarEvent -> CalendarEvent -> Bool # (>=) :: CalendarEvent -> CalendarEvent -> Bool # max :: CalendarEvent -> CalendarEvent -> CalendarEvent # min :: CalendarEvent -> CalendarEvent -> CalendarEvent # | |
Show CalendarEvent Source # | |
Defined in RON.Event showsPrec :: Int -> CalendarEvent -> ShowS # show :: CalendarEvent -> String # showList :: [CalendarEvent] -> ShowS # |
data EpochEvent Source #
Epoch-based Lamport time event, specific case of Event
.
Instances
Eq EpochEvent Source # | |
Defined in RON.Event (==) :: EpochEvent -> EpochEvent -> Bool # (/=) :: EpochEvent -> EpochEvent -> Bool # | |
Ord EpochEvent Source # | |
Defined in RON.Event compare :: EpochEvent -> EpochEvent -> Ordering # (<) :: EpochEvent -> EpochEvent -> Bool # (<=) :: EpochEvent -> EpochEvent -> Bool # (>) :: EpochEvent -> EpochEvent -> Bool # (>=) :: EpochEvent -> EpochEvent -> Bool # max :: EpochEvent -> EpochEvent -> EpochEvent # min :: EpochEvent -> EpochEvent -> EpochEvent # | |
Show EpochEvent Source # | |
Defined in RON.Event showsPrec :: Int -> EpochEvent -> ShowS # show :: EpochEvent -> String # showList :: [EpochEvent] -> ShowS # |
type EpochTime = Word60 Source #
RFC 4122 epoch, hundreds of nanoseconds since 1582. Year range is 1582—5235.
Generic Lamport time event.
Cannot be Ord
because we can't compare different types of clocks.
If you want comparable events, use specific EpochEvent
.
Clock type is encoded in 2 higher bits of variety, value in uuidValue
Replica id assignment style
class Monad m => ReplicaClock m where Source #
getPid :: m ReplicaId Source #
Get current replica id
:: EpochTime | number of needed timestamps |
-> m [EpochEvent] |
Get sequential timestamps.
Laws:
advance :: EpochTime -> m () Source #
Make local time not less than this
Instances
ReplicaClock EpochClock Source # | |
Defined in RON.Epoch getPid :: EpochClock ReplicaId Source # getEvents :: EpochTime -> EpochClock [EpochEvent] Source # advance :: EpochTime -> EpochClock () Source # | |
Monad m => ReplicaClock (ReplicaSimT m) Source # | |
Defined in RON.Event.Simulation getPid :: ReplicaSimT m ReplicaId Source # getEvents :: EpochTime -> ReplicaSimT m [EpochEvent] Source # advance :: EpochTime -> ReplicaSimT m () Source # | |
ReplicaClock m => ReplicaClock (ExceptT e m) Source # | |
ReplicaClock m => ReplicaClock (ReaderT r m) Source # | |
ReplicaClock m => ReplicaClock (StateT s m) Source # | |
ReplicaClock m => ReplicaClock (WriterT s m) Source # | |
Replica identifier
Instances
Eq ReplicaId Source # | |
Show ReplicaId Source # | |
Generic ReplicaId Source # | |
Hashable ReplicaId Source # | |
type Rep ReplicaId Source # | |
Defined in RON.Event type Rep ReplicaId = D1 (MetaData "ReplicaId" "RON.Event" "ron-0.9-3vRSvkBw59E3vYQ9Q1curT" False) (C1 (MetaCons "ReplicaId" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Naming) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness SourceStrict DecidedStrict) (Rec0 Word60))) |
advanceToUuid :: ReplicaClock clock => UUID -> clock () Source #
advance
variant for any UUID
applicationSpecific :: Word64 -> ReplicaId Source #
Make an ApplicationSpecific
replica id from arbitrary number
decodeEvent :: UUID -> Event Source #
encodeEvent :: Event -> UUID Source #
fromEpochEvent :: EpochEvent -> Event Source #
getEvent :: (HasCallStack, ReplicaClock m) => m EpochEvent Source #
Get a single event
getEventUuid :: ReplicaClock m => m UUID Source #
Get a single event as UUID
getEventUuids :: ReplicaClock m => Word60 -> m [UUID] Source #
Get event sequence as UUIDs
:: (Word16, Word16, Word8) | date as (year, month [1..12], day [1..]) |
-> Maybe CalendarTime |
Make a calendar timestamp from a date
:: (Word16, Word16, Word8) | date as (year, month [1..12], day [1..]) |
-> (Word8, Word8, Word8) | day time as (hours, minutes, seconds) |
-> Maybe CalendarTime |
Make a calendar timestamp from a date and a day time
mkCalendarDateTimeNano Source #
:: (Word16, Word16, Word8) | date as (year, month [1..12], day [1..]) |
-> (Word8, Word8, Word8) | day time as (hours, minutes, seconds) |
-> Word32 | fraction of a second in hundreds of nanosecond |
-> Maybe CalendarTime |
Make a calendar timestamp from a date, a day time, and a second fraction
toEpochEvent :: Event -> Maybe EpochEvent Source #