pituicat/src/Affection/MessageBus/Message.hs

19 lines
449 B
Haskell
Raw Normal View History

2017-11-27 00:43:43 +00:00
{-# LANGUAGE RankNTypes #-}
2017-11-26 21:26:41 +00:00
module Affection.MessageBus.Message where
2017-11-27 00:43:43 +00:00
import Data.Time.Clock (UTCTime(..))
2017-11-26 21:26:41 +00:00
class Message msg where
2017-11-27 00:43:43 +00:00
msgTime :: msg -> UTCTime
2017-11-27 01:18:23 +00:00
data SystemMessage m
2017-11-27 00:43:43 +00:00
= MsgUserMessage
{ msgPayload :: m
, msgWhen :: UTCTime
} -- ^ Generic user defined message with custom payload
| MsgEngineReady UTCTime
2017-11-27 01:18:23 +00:00
instance Message (SystemMessage m) where
2017-11-27 00:43:43 +00:00
msgTime (MsgUserMessage _ t) = t
msgTime (MsgEngineReady t) = t