From 8bf06c678588ca4b7d70226f88ec4e108c8afc96 Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Tue, 13 May 2025 11:13:20 +0200 Subject: [PATCH 1/2] haddocks: added a note on resource allocation --- .../src/Network/TypedProtocol/Stateful/Peer.hs | 9 ++++++++- typed-protocols/src/Network/TypedProtocol/Peer.hs | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/typed-protocols-stateful/src/Network/TypedProtocol/Stateful/Peer.hs b/typed-protocols-stateful/src/Network/TypedProtocol/Stateful/Peer.hs index 275ef953..f821d69b 100644 --- a/typed-protocols-stateful/src/Network/TypedProtocol/Stateful/Peer.hs +++ b/typed-protocols-stateful/src/Network/TypedProtocol/Stateful/Peer.hs @@ -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. diff --git a/typed-protocols/src/Network/TypedProtocol/Peer.hs b/typed-protocols/src/Network/TypedProtocol/Peer.hs index 1f1097c1..d95e55a1 100644 --- a/typed-protocols/src/Network/TypedProtocol/Peer.hs +++ b/typed-protocols/src/Network/TypedProtocol/Peer.hs @@ -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 From 6e167d45a432952f2e9adaab83a956a3ad9897c9 Mon Sep 17 00:00:00 2001 From: Marcin Szamotulski Date: Wed, 14 May 2025 15:58:13 +0200 Subject: [PATCH 2/2] GHC 9.10 & 9.12 support --- cabal.project | 9 +++------ typed-protocols-doc/typed-protocols-doc.cabal | 4 ++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/cabal.project b/cabal.project index 603ffbf4..aa3a5229 100644 --- a/cabal.project +++ b/cabal.project @@ -1,4 +1,4 @@ -index-state: 2025-01-30T00:54:30Z +index-state: 2025-05-05T00:00:00Z packages: ./typed-protocols ./typed-protocols-cborg @@ -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 diff --git a/typed-protocols-doc/typed-protocols-doc.cabal b/typed-protocols-doc/typed-protocols-doc.cabal index 3d368773..c157dcd5 100644 --- a/typed-protocols-doc/typed-protocols-doc.cabal +++ b/typed-protocols-doc/typed-protocols-doc.cabal @@ -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 @@ -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