2017-11-27 00:43:43 +00:00
|
|
|
{-# LANGUAGE MultiParamTypeClasses #-}
|
2017-11-26 21:26:41 +00:00
|
|
|
module Affection.MessageBus.Class where
|
|
|
|
|
|
|
|
import Control.Concurrent.STM as STM
|
|
|
|
|
|
|
|
import Data.IORef
|
|
|
|
|
|
|
|
import Affection.MessageBus.Message
|
|
|
|
|
2017-11-27 00:43:43 +00:00
|
|
|
newtype (Message msg) => Channel msg = Channel (TChan msg)
|
2017-11-26 21:26:41 +00:00
|
|
|
|
2017-11-27 00:43:43 +00:00
|
|
|
class (Message msg) => Participant prt msg where
|
|
|
|
partChannel :: prt -> IORef (Channel msg)
|
2017-11-26 21:26:41 +00:00
|
|
|
|
2017-11-27 00:43:43 +00:00
|
|
|
partConnectChannel :: prt -> Channel msg -> IO ()
|
2017-11-26 21:26:41 +00:00
|
|
|
|
2017-11-27 00:43:43 +00:00
|
|
|
partListen :: prt -> IO msg
|
2017-11-26 21:26:41 +00:00
|
|
|
|
2017-11-27 01:18:23 +00:00
|
|
|
partEmit :: prt -> msg -> IO ()
|