pituicat/src/Affection/MessageBus/Class.hs
2017-12-12 13:12:27 +01:00

34 lines
1.1 KiB
Haskell

{-# LANGUAGE MultiParamTypeClasses #-}
module Affection.MessageBus.Class where
import Affection.MessageBus.Message
import Affection.Types
class (Message m) => Participant prt m where
-- | get the outbound 'Channel' of the 'Participant'
partChannel
:: prt -- ^ The 'Participant'
-> Channel m -- ^ Outbound 'Channel'
-- | Initialize the 'Participant' with an inbound 'Channel'
partInit
:: Channel m -- ^ Inbound 'Channel' the 'Participant' will listen to
-> Affection sd prt -- ^ The constructed and initialized 'Participant'
-- Get the 'Participant' to listen to its inbound 'Channel'
partListen
:: prt -- ^ The 'Participant'
-> Affection sd (Maybe m) -- ^ The optional 'Message' peeked from the 'Channel'
-- Get the 'Participant' to emit a Message on its outbound 'Channel'
partEmit
:: prt -- ^ The 'Participant'
-> m -- ^ The 'Message' to emit
-> Affection sd ()
-- data Envelope = Envelope
-- { envFrom :: (Participant a _) => a
-- , envTo :: (Participant b _) => b
-- , envMessage :: (Message msg) => msg
-- }