typed-protocols:examples
Safe HaskellNone
LanguageGHC2021

Network.TypedProtocol.ReqResp.Server

Synopsis

Documentation

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

Constructors

ReqRespServer 

Fields

  • recvMsgReq :: req -> m (resp, ReqRespServer req resp m a)

    The client sent us a ping message. We have no choices here, and the response is nullary, all we have are local effects.

  • recvMsgDone :: m a

    The client terminated. Here we have a pure return value, but we could have done another action in m if we wanted to.

reqRespServerPeer :: forall (m :: Type -> Type) req resp a. Monad m => ReqRespServer req resp m a -> Server (ReqResp req resp) ('NonPipelined :: IsPipelined (ReqResp req resp)) ('StIdle :: ReqResp req resp) m a Source #

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

reqRespServerPeerLookahead Source #

Arguments

:: forall resp m. Functor m 
=> m resp

produce (and record) the next reply

-> ServerLookahead (ReqResp () resp) ('StIdle :: ReqResp () resp) m () 

A lookahead ReqResp server (the dual of a pipelined client).

It is exactly reqRespServerPeerLookaheadFixedSender with its single Sender plugged in at each AwaitLookahead (via embedLookaheadUsingFixedSender), so the two never drift apart.

reqRespServerPeerLookaheadFixedSender Source #

Arguments

:: forall resp m. Functor m 
=> m resp

produce (and record) the next reply

-> ServerLookaheadFixedSender (ReqResp () resp) ('StIdle :: ReqResp () resp) m () 

A lookahead ReqResp server that receives requests ahead of sending their replies: each AwaitLookahead hands the reply to the previous request off to the sender thread (via TheSender, the one Sender carried by the ServerLookaheadFixedSender wrapper — it runs nextResp, which typically reads and advances some state), while immediately awaiting the next request. The request payload is ignored (hence ()); replies come solely from nextResp. This is the peer that runLookaheadFixedSenderPeerWithDriver runs.