summaryrefslogtreecommitdiff
path: root/P2P
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-11-30 23:54:00 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-11-30 23:54:00 -0400
commita36bac3f0a8775d2516f22f10e237701df61a8c6 (patch)
treec7c039e2b3ae6e29baa74dbb93ced1a7182a1d87 /P2P
parentad7afb05bba11b372d66a6d5b685e013bb79a1a3 (diff)
better comments
Diffstat (limited to 'P2P')
-rw-r--r--P2P/IO.hs10
1 files changed, 8 insertions, 2 deletions
diff --git a/P2P/IO.hs b/P2P/IO.hs
index c0b14edca..82ad23646 100644
--- a/P2P/IO.hs
+++ b/P2P/IO.hs
@@ -32,6 +32,7 @@ import Control.Concurrent.Async
import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as L
+-- Type of interpreters of the Proto free monad.
type RunProto = forall a m. (MonadIO m, MonadMask m) => Proto a -> m (Maybe a)
data RunEnv = RunEnv
@@ -41,8 +42,10 @@ data RunEnv = RunEnv
, runOhdl :: Handle
}
--- Implementation of the protocol, communicating with a peer
--- over a Handle. No Local actions will be run.
+-- Interpreter of Proto that communicates with a peer over a Handle.
+--
+-- No Local actions will be run; if the interpreter reaches any,
+-- it returns Nothing.
runNetProtoHandle :: (MonadIO m, MonadMask m) => RunEnv -> Proto a -> m (Maybe a)
runNetProtoHandle runenv = go
where
@@ -51,6 +54,9 @@ runNetProtoHandle runenv = go
go (Free (Net n)) = runNetHandle runenv go n
go (Free (Local _)) = return Nothing
+-- Interprater of Net that communicates with a peer over a Handle.
+--
+-- An interpreter for Proto has to be provided.
runNetHandle :: (MonadIO m, MonadMask m) => RunEnv -> RunProto -> NetF (Proto a) -> m (Maybe a)
runNetHandle runenv runner f = case f of
SendMessage m next -> do