typed-protocols-examples
Safe HaskellNone
LanguageHaskell2010

Network.TypedProtocol.ReqResp.Client

Synopsis

Normal client

data ReqRespClient req resp (m :: Type -> Type) a where Source #

Constructors

SendMsgReq :: forall req resp (m :: Type -> Type) a. req -> (resp -> m (ReqRespClient req resp m a)) -> ReqRespClient req resp m a 
SendMsgDone :: forall (m :: Type -> Type) a req resp. m a -> ReqRespClient req resp m a 

reqRespClientPeer :: forall (m :: Type -> Type) req resp a. Monad m => ReqRespClient req resp m a -> Client (ReqResp req resp) 'NonPipelined ('StIdle :: ReqResp req resp) m a Source #

Interpret a particular client action sequence into the client side of the ReqResp protocol.

Pipelined client

data ReqRespClientPipelined req resp (m :: Type -> Type) a where Source #

A request-response client designed for running the ReqResp protocol in a pipelined way.

Constructors

ReqRespClientPipelined :: forall req resp c (m :: Type -> Type) a. ReqRespIdle req resp 'Z c m a -> ReqRespClientPipelined req resp m a

A PingPongSender, but starting with zero outstanding pipelined responses, and for any internal collect type c.

reqRespClientPeerPipelined :: forall (m :: Type -> Type) req resp a. Functor m => ReqRespClientPipelined req resp m a -> ClientPipelined (ReqResp req resp) ('StIdle :: ReqResp req resp) m a Source #

Interpret a pipelined client as a Peer on the client side of the ReqResp protocol.

data ReqRespIdle req resp (n :: N) c (m :: Type -> Type) a where Source #

Constructors

SendMsgReqPipelined :: forall req resp (m :: Type -> Type) c (n :: N) a. req -> (resp -> m c) -> ReqRespIdle req resp ('S n) c m a -> ReqRespIdle req resp n c m a

Send a Req message but alike in ReqRespClient do not await for the resopnse, instead supply a monadic action which will run on a received Pong message.

CollectPipelined :: forall req resp (n1 :: N) c (m :: Type -> Type) a. Maybe (ReqRespIdle req resp ('S n1) c m a) -> (c -> m (ReqRespIdle req resp n1 c m a)) -> ReqRespIdle req resp ('S n1) c m a 
SendMsgDonePipelined :: forall a req resp c (m :: Type -> Type). a -> ReqRespIdle req resp 'Z c m a

Termination of the req-resp protocol.

reqRespClientPeerIdle :: forall req resp (n :: N) c (m :: Type -> Type) a. Functor m => ReqRespIdle req resp n c m a -> Client (ReqResp req resp) ('Pipelined n c) ('StIdle :: ReqResp req resp) m a Source #

Request once

requestOnce :: forall req resp m. Monad m => (forall x. Server (ReqResp req resp) 'NonPipelined ('StIdle :: ReqResp req resp) m x) -> req -> m resp Source #