helic-0.1.0.0: lib/Helic/Data/Event.hs
-- |Event Data Type
module Helic.Data.Event where
import qualified Chronos
import Polysemy.Chronos (ChronosTime)
import qualified Polysemy.Time as Time
import Helic.Data.AgentId (AgentId)
import Helic.Data.InstanceName (InstanceName)
-- |The central data type representing a clipboard event.
data Event =
Event {
-- |The host from which the event originated.
sender :: InstanceName,
-- |The entity that caused the event.
source :: AgentId,
-- |Timestamp.
time :: Chronos.Time,
-- |Payload.
content :: Text
}
deriving stock (Eq, Show)
defaultJson ''Event
-- |Construct an event for the current host and time.
now ::
Members [ChronosTime, Reader InstanceName] r =>
AgentId ->
Text ->
Sem r Event
now source content = do
sender <- ask
time <- Time.now
pure Event {..}