From aa7be8488399197ba2a70ab546dc4ba9c7721520 Mon Sep 17 00:00:00 2001 From: nek0 Date: Tue, 12 Dec 2017 13:12:27 +0100 Subject: [PATCH] moar documentation --- src/Affection/MessageBus/Class.hs | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/Affection/MessageBus/Class.hs b/src/Affection/MessageBus/Class.hs index 80a1c51..b83e99b 100644 --- a/src/Affection/MessageBus/Class.hs +++ b/src/Affection/MessageBus/Class.hs @@ -1,15 +1,33 @@ {-# LANGUAGE MultiParamTypeClasses #-} -{-# LANGUAGE AllowAmbiguousTypes #-} module Affection.MessageBus.Class where import Affection.MessageBus.Message import Affection.Types -class Participant prt m where - partChannel :: prt -> Channel m +class (Message m) => Participant prt m where + -- | get the outbound 'Channel' of the 'Participant' + partChannel + :: prt -- ^ The 'Participant' + -> Channel m -- ^ Outbound 'Channel' - partInit :: Affection sd m prt + -- | 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' - partListen :: prt -> IO (Maybe m) + -- Get the 'Participant' to listen to its inbound 'Channel' + partListen + :: prt -- ^ The 'Participant' + -> Affection sd (Maybe m) -- ^ The optional 'Message' peeked from the 'Channel' - partEmit :: prt -> m -> IO () + -- 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 +-- }