Skip to content

haddocks: added a note on resource allocation #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
index-state: 2025-01-30T00:54:30Z
index-state: 2025-05-05T00:00:00Z

packages: ./typed-protocols
./typed-protocols-cborg
Expand All @@ -11,11 +11,8 @@ test-show-details: direct

if impl(ghc >= 9.12)
allow-newer:
-- https://github.com/well-typed/cborg/pull/339
, cborg:base
, cborg:ghc-prim
, serialise:base
, serialise:ghc-prim
, serdoc-core:template-haskell
, serdoc-core:th-abstraction

if os(windows)
package text
Expand Down
4 changes: 2 additions & 2 deletions typed-protocols-doc/typed-protocols-doc.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ library
, base64-bytestring >=1.2.1.0 && <1.3
, blaze-html >=0.9.1.2 && <0.10
, bytestring >=0.11 && <0.13
, containers >=0.6.8 && <0.7
, containers >=0.6.8 && <0.8
, fgl >=5.7 && <5.9
, filepath >=1.4.2.2 && <1.6
, graphviz >=2999.20.1 && <2999.21.0
Expand All @@ -51,7 +51,7 @@ library
, template-haskell >=2.13.0.0
, temporary >=1.3 && <1.4
, text >=1.1 && <2.2
, th-abstraction >=0.6.0.0 && <0.7
, th-abstraction >=0.6.0.0 && <0.8
, time >=1.12 && <1.14
, serdoc-core
, typed-protocols
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,14 @@ import Network.TypedProtocol.Core as Core
-- 'Network.TypedProtocol.Peer.Client' or 'Network.TypedProtocol.Peer.Server'
-- pattern synonyms provide this evidence automatically.
--
-- TODO:
-- __NOTE__:
-- one should not allocate resources within a `Peer` since there's no way to
-- safely clean-up resources in case of an asynchronous exception. The proper
-- way to allocate resources is to call
-- `Network.TypedProtocol.Stateful.Driver.runPeerWithDriver` within
-- a `Control.Exception.bracket`.
--
-- __TODO__:
-- We are not exposing pipelined version, since it is not possible to write
-- a driver & proofs in a type safe which take into account the state when the
-- peer type only tracks depth of pipelining rather than pipelined transitions.
Expand Down
7 changes: 7 additions & 0 deletions typed-protocols/src/Network/TypedProtocol/Peer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ import Network.TypedProtocol.Core as Core
-- "Network.TypedProtocol.Peer.Client" supply this evidence for you, and hence
-- are easier to use and let you avoid some kinds of type errors.
--
-- __NOTE__:
-- one should not allocate resources within a `Peer` since there's no way to
-- safely clean-up resources in case of an asynchronous exception. The proper
-- way to allocate resources is to call
-- `Network.TypedProtocol.Driver.runPeerWithDriver` (or `runPeer`,
-- `runPipelinedPeer`) within a `Control.Exception.bracket`.
--
type Peer :: forall ps
-> PeerRole
-> IsPipelined
Expand Down