Skip to content

Commit 03270e4

Browse files
committed
typed-protocols: renamed Pipelined kind to IsPipelined
This allows us to not worry about the promoted type and kind to have the same name.
1 parent 558a9fc commit 03270e4

File tree

9 files changed

+41
-36
lines changed

9 files changed

+41
-36
lines changed

typed-protocols-examples/src/Network/TypedProtocol/PingPong/Client.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,20 +141,20 @@ data PingPongClientIdle (n :: Outstanding) c m a where
141141
pingPongClientPeerPipelined
142142
:: Functor m
143143
=> PingPongClientPipelined c m a
144-
-> Client PingPong ('Pipelined c) Z StIdle m a
144+
-> Client PingPong (Pipelined c) Z StIdle m a
145145
pingPongClientPeerPipelined (PingPongClientPipelined peer) =
146146
pingPongClientPeerIdle peer
147147

148148

149149
pingPongClientPeerIdle
150150
:: forall (n :: Outstanding) c m a. Functor m
151151
=> PingPongClientIdle n c m a
152-
-> Client PingPong ('Pipelined c) n StIdle m a
152+
-> Client PingPong (Pipelined c) n StIdle m a
153153
pingPongClientPeerIdle = go
154154
where
155155
go :: forall (n' :: Outstanding).
156156
PingPongClientIdle n' c m a
157-
-> Client PingPong ('Pipelined c) n' StIdle m a
157+
-> Client PingPong (Pipelined c) n' StIdle m a
158158

159159
go (SendMsgPingPipelined receive next) =
160160
-- Pipelined yield: send `MsgPing`, immediately follow with the next step.

typed-protocols-examples/src/Network/TypedProtocol/ReqResp/Client.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ data ReqRespIdle req resp c n m a where
118118
reqRespClientPeerPipelined
119119
:: Functor m
120120
=> ReqRespClientPipelined req resp c m a
121-
-> Client (ReqResp req resp) ('Pipelined c) Z StIdle m a
121+
-> Client (ReqResp req resp) (Pipelined c) Z StIdle m a
122122
reqRespClientPeerPipelined (ReqRespClientPipelined peer) =
123123
reqRespClientPeerIdle peer
124124

@@ -127,13 +127,13 @@ reqRespClientPeerIdle
127127
:: forall req resp n c m a.
128128
Functor m
129129
=> ReqRespIdle req resp c n m a
130-
-> Client (ReqResp req resp) ('Pipelined c) n StIdle m a
130+
-> Client (ReqResp req resp) (Pipelined c) n StIdle m a
131131

132132
reqRespClientPeerIdle = go
133133
where
134134
go :: forall n'.
135135
ReqRespIdle req resp c n' m a
136-
-> Client (ReqResp req resp) ('Pipelined c) n' StIdle m a
136+
-> Client (ReqResp req resp) (Pipelined c) n' StIdle m a
137137

138138
go (SendMsgReqPipelined req receive next) =
139139
-- Pipelined yield: send `MsgReq`, immediately follow with the next step.

typed-protocols-examples/src/Network/TypedProtocol/ReqResp2/Client.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ import Network.TypedProtocol.Peer.Client
2121
reqResp2Client :: forall req resp m.
2222
()
2323
=> [Either req req]
24-
-> Client (ReqResp2 req resp) ('Pipelined (Either resp resp)) Z StIdle m [Either resp resp]
24+
-> Client (ReqResp2 req resp) (Pipelined (Either resp resp)) Z StIdle m [Either resp resp]
2525
reqResp2Client = send Zero
2626
where
2727
-- pipeline all the requests, either through `MsgReq` or `MsgReq'`.
2828
send :: forall (n :: N).
2929
Nat n
3030
-> [Either req req] -- requests to send
31-
-> Client (ReqResp2 req resp) ('Pipelined (Either resp resp)) n StIdle m [Either resp resp]
31+
-> Client (ReqResp2 req resp) (Pipelined (Either resp resp)) n StIdle m [Either resp resp]
3232

3333
send !n (Left req : reqs) =
3434
YieldPipelined (MsgReq req) receiver (send (Succ n) reqs)
@@ -50,7 +50,7 @@ reqResp2Client = send Zero
5050
-- collect all the responses
5151
collect :: Nat n
5252
-> [Either resp resp] -- all the responses received so far
53-
-> Client (ReqResp2 req resp) ('Pipelined (Either resp resp)) n StIdle m [Either resp resp]
53+
-> Client (ReqResp2 req resp) (Pipelined (Either resp resp)) n StIdle m [Either resp resp]
5454

5555
collect Zero !resps = Yield MsgDone (Done (reverse resps))
5656

typed-protocols-examples/src/Network/TypedProtocol/Trans/Wedge.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ pingPong2Client =
125125
$ Client.Done ()
126126

127127

128-
pingPong2Client' :: forall m. Client.Client PingPong2 ('Pipelined ()) Client.Z StIdle m ()
128+
pingPong2Client' :: forall m. Client.Client PingPong2 (Pipelined ()) Client.Z StIdle m ()
129129
pingPong2Client' =
130130
--
131131
-- Pipeline first protocol

typed-protocols/src/Network/TypedProtocol/Core.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ module Network.TypedProtocol.Core
4141
, TheyHaveAgencyProof
4242
, NobodyHasAgencyProof
4343
, FlipAgency
44-
, Pipelined (..)
44+
, IsPipelined (..)
4545
, ActiveAgency
4646
, ActiveAgency' (..)
4747
, IsActiveState (..)
@@ -476,10 +476,10 @@ type family FlipAgency pr where
476476
-- | Promoted data type which indicates if 'Peer' is used in
477477
-- pipelined mode or not.
478478
--
479-
data Pipelined where
479+
data IsPipelined where
480480
-- | Pipelined peer which is using `c :: Type` for collecting responses
481481
-- from a pipelined messages.
482-
Pipelined :: Type -> Pipelined
482+
Pipelined :: Type -> IsPipelined
483483

484484
-- | Non-pipelined peer.
485-
NonPipelined :: Pipelined
485+
NonPipelined :: IsPipelined

typed-protocols/src/Network/TypedProtocol/Peer.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ import Network.TypedProtocol.Core as Core
9595
--
9696
type Peer :: forall ps
9797
-> PeerRole
98-
-> Pipelined
98+
-> IsPipelined
9999
-> Outstanding
100100
-> ps
101101
-> (Type -> Type)
@@ -209,9 +209,9 @@ data Peer ps pr pl n st m a where
209209
-> Message ps st st'
210210
-- ^ protocol message
211211
-> Receiver ps pr st' st'' m c
212-
-> Peer ps pr ('Pipelined c) (S n) st'' m a
212+
-> Peer ps pr (Pipelined c) (S n) st'' m a
213213
-- ^ continuation
214-
-> Peer ps pr ('Pipelined c) n st m a
214+
-> Peer ps pr (Pipelined c) n st m a
215215

216216
-- | Partially collect promised transition.
217217
--
@@ -220,11 +220,11 @@ data Peer ps pr pl n st m a where
220220
( SingI st
221221
, ActiveState st
222222
)
223-
=> Maybe (Peer ps pr ('Pipelined c) (S n) st m a)
223+
=> Maybe (Peer ps pr (Pipelined c) (S n) st m a)
224224
-- ^ continuation, executed if no message has arrived so far
225-
-> (c -> Peer ps pr ('Pipelined c) n st m a)
225+
-> (c -> Peer ps pr (Pipelined c) n st m a)
226226
-- ^ continuation
227-
-> Peer ps pr ('Pipelined c) (S n) st m a
227+
-> Peer ps pr (Pipelined c) (S n) st m a
228228

229229
deriving instance Functor m => Functor (Peer ps pr pl n st m)
230230

typed-protocols/src/Network/TypedProtocol/Peer/Client.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module Network.TypedProtocol.Peer.Client
2424
, pattern ReceiverAwait
2525
, pattern ReceiverDone
2626
-- * re-exports
27-
, Pipelined (..)
27+
, IsPipelined (..)
2828
, Outstanding
2929
, N (..)
3030
, Nat (..)
@@ -40,7 +40,7 @@ import qualified Network.TypedProtocol.Peer as TP
4040

4141

4242
type Client :: forall ps
43-
-> Pipelined
43+
-> IsPipelined
4444
-> Outstanding
4545
-> ps
4646
-> (Type -> Type)
@@ -114,9 +114,9 @@ pattern YieldPipelined :: forall ps st n c m a.
114114
=> Message ps st st'
115115
-- ^ pipelined message
116116
-> Receiver ps st' st'' m c
117-
-> Client ps ('Pipelined c) (S n) st'' m a
117+
-> Client ps (Pipelined c) (S n) st'' m a
118118
-- ^ continuation
119-
-> Client ps ('Pipelined c) n st m a
119+
-> Client ps (Pipelined c) n st m a
120120
pattern YieldPipelined msg receiver k = TP.YieldPipelined ReflClientAgency msg receiver k
121121

122122

@@ -127,11 +127,11 @@ pattern Collect :: forall ps st n c m a.
127127
=> ( SingI st
128128
, ActiveState st
129129
)
130-
=> Maybe (Client ps ('Pipelined c) (S n) st m a)
130+
=> Maybe (Client ps (Pipelined c) (S n) st m a)
131131
-- ^ continuation, executed if no message has arrived so far
132-
-> (c -> Client ps ('Pipelined c) n st m a)
132+
-> (c -> Client ps (Pipelined c) n st m a)
133133
-- ^ continuation
134-
-> Client ps ('Pipelined c) (S n) st m a
134+
-> Client ps (Pipelined c) (S n) st m a
135135
pattern Collect k' k = TP.Collect k' k
136136

137137
{-# COMPLETE Effect, Yield, Await, Done, YieldPipelined, Collect #-}

typed-protocols/src/Network/TypedProtocol/Peer/Server.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module Network.TypedProtocol.Peer.Server
2424
, pattern ReceiverAwait
2525
, pattern ReceiverDone
2626
-- * re-exports
27-
, Pipelined (..)
27+
, IsPipelined (..)
2828
, Outstanding
2929
, N (..)
3030
, Nat (..)
@@ -40,7 +40,7 @@ import qualified Network.TypedProtocol.Peer as TP
4040

4141

4242
type Server :: forall ps
43-
-> Pipelined
43+
-> IsPipelined
4444
-> Outstanding
4545
-> ps
4646
-> (Type -> Type)
@@ -114,9 +114,9 @@ pattern YieldPipelined :: forall ps st n c m a.
114114
=> Message ps st st'
115115
-- ^ pipelined message
116116
-> Receiver ps st' st'' m c
117-
-> Server ps ('Pipelined c) (S n) st'' m a
117+
-> Server ps (Pipelined c) (S n) st'' m a
118118
-- ^ continuation
119-
-> Server ps ('Pipelined c) n st m a
119+
-> Server ps (Pipelined c) n st m a
120120
pattern YieldPipelined msg receiver k = TP.YieldPipelined ReflServerAgency msg receiver k
121121

122122

@@ -127,11 +127,11 @@ pattern Collect :: forall ps st n c m a.
127127
=> ( SingI st
128128
, ActiveState st
129129
)
130-
=> Maybe (Server ps ('Pipelined c) (S n) st m a)
130+
=> Maybe (Server ps (Pipelined c) (S n) st m a)
131131
-- ^ continuation, executed if no message has arrived so far
132-
-> (c -> Server ps ('Pipelined c) n st m a)
132+
-> (c -> Server ps (Pipelined c) n st m a)
133133
-- ^ continuation
134-
-> Server ps ('Pipelined c) (S n) st m a
134+
-> Server ps (Pipelined c) (S n) st m a
135135
pattern Collect k' k = TP.Collect k' k
136136

137137

typed-protocols/src/Network/TypedProtocol/Proofs.hs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,13 @@ forgetPipelined
172172
:: forall ps (pr :: PeerRole) (st :: ps) c m a.
173173
Functor m
174174
=> [Bool]
175-
-> Peer ps pr ('Pipelined c) Z st m a
176-
-> Peer ps pr 'NonPipelined Z st m a
175+
-- ^ interleaving choices for pipelining allowed by
176+
-- `Collect` and `CollectSTM` primitive. False values or `[]` give no
177+
-- pipelining. For the 'CollectSTM' primitive, the stm action must not
178+
-- block otherwise even if the choice is to pipeline more (a 'True' value),
179+
-- we'll actually collect a result.
180+
-> Peer ps pr (Pipelined c) Z st m a
181+
-> Peer ps pr NonPipelined Z st m a
177182
forgetPipelined = goSender EmptyQ
178183
where
179184
goSender :: forall st' n.

0 commit comments

Comments
 (0)