Skip to content

Commit 8bf06c6

Browse files
committed
haddocks: added a note on resource allocation
1 parent a177c88 commit 8bf06c6

File tree

2 files changed

+15
-1
lines changed
  • typed-protocols-stateful/src/Network/TypedProtocol/Stateful
  • typed-protocols/src/Network/TypedProtocol

2 files changed

+15
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,14 @@ import Network.TypedProtocol.Core as Core
6767
-- 'Network.TypedProtocol.Peer.Client' or 'Network.TypedProtocol.Peer.Server'
6868
-- pattern synonyms provide this evidence automatically.
6969
--
70-
-- TODO:
70+
-- __NOTE__:
71+
-- one should not allocate resources within a `Peer` since there's no way to
72+
-- safely clean-up resources in case of an asynchronous exception. The proper
73+
-- way to allocate resources is to call
74+
-- `Network.TypedProtocol.Stateful.Driver.runPeerWithDriver` within
75+
-- a `Control.Exception.bracket`.
76+
--
77+
-- __TODO__:
7178
-- We are not exposing pipelined version, since it is not possible to write
7279
-- a driver & proofs in a type safe which take into account the state when the
7380
-- peer type only tracks depth of pipelining rather than pipelined transitions.

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ import Network.TypedProtocol.Core as Core
7979
-- "Network.TypedProtocol.Peer.Client" supply this evidence for you, and hence
8080
-- are easier to use and let you avoid some kinds of type errors.
8181
--
82+
-- __NOTE__:
83+
-- one should not allocate resources within a `Peer` since there's no way to
84+
-- safely clean-up resources in case of an asynchronous exception. The proper
85+
-- way to allocate resources is to call
86+
-- `Network.TypedProtocol.Driver.runPeerWithDriver` (or `runPeer`,
87+
-- `runPipelinedPeer`) within a `Control.Exception.bracket`.
88+
--
8289
type Peer :: forall ps
8390
-> PeerRole
8491
-> IsPipelined

0 commit comments

Comments
 (0)