resource-registry 0.2.0.0 → 0.2.1.0
raw patch · 3 files changed
+29/−5 lines, 3 files
Files
- CHANGELOG.md +5/−0
- resource-registry.cabal +5/−5
- src/Control/ResourceRegistry.hs +19/−0
CHANGELOG.md view
@@ -1,5 +1,10 @@ # Revision history of `resource-registry` +## 0.2.1.0 - 2026-03-04++* Define `impossibleToNotTransfer` for fundamental resource allocation in+ `WithTempRegistry`.+ ## 0.2.0.0 — 2025-10-23 * Define `transferRegistry` for moving all resources from one registry to a
resource-registry.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: resource-registry-version: 0.2.0.0+version: 0.2.1.0 synopsis: Track allocated resources description: When the scope of a @bracket@ doesn't enclose all uses of the resource, a@@ -54,12 +54,12 @@ import: warnings exposed-modules: Control.ResourceRegistry build-depends:- base >=4.14 && <4.22,+ base >=4.14 && <4.23, bimap ^>=0.5,- containers >=0.6.7 && <0.8,- io-classes:{io-classes, strict-stm} ^>=1.8,+ containers >=0.6.7 && <0.9,+ io-classes:{io-classes, strict-stm} ^>=1.8 || ^>=1.9, mtl ^>=2.3,- nothunks ^>=0.2,+ nothunks ^>=0.2 || ^>=0.3, hs-source-dirs: src default-language: Haskell2010
src/Control/ResourceRegistry.hs view
@@ -265,6 +265,7 @@ , runInnerWithTempRegistry , runWithTempRegistry , transferRegistry+ , impossibleToNotTransfer -- * Unsafe combinators primarily for testing , closeRegistry@@ -862,6 +863,17 @@ whenJust (Just x) f = f x whenJust Nothing _ = pure () +-- | This combinator can be used with 'allocateTemp' to indicate that the+-- resource will always be considered tracked in the final state.+--+-- > allocateTemp alloc free impossibleToNotTransfer+--+-- Using this combinator will result in the resource only being closed on+-- exceptions that happen during the 'runWithTempRegistry' scope, very much like+-- 'bracketOnError' would.+impossibleToNotTransfer :: a -> b -> Bool+impossibleToNotTransfer _ _ = True+ -- | Embed a self-contained 'WithTempRegistry' computation into a larger one. -- -- The internal 'WithTempRegistry' is effectively passed to@@ -998,6 +1010,13 @@ -- | Allocate a resource in a temporary registry until it has been transferred -- to the final state @st@. See 'runWithTempRegistry' for more details.+--+-- Sometimes the resource will necessarily end up in the final state with no+-- possible way in which such state does exist without holding the resource. In+-- such cases, we can use 'allocateTemp' very much like a 'bracketOnError' to+-- take care of releasing the resource only if an exception comes. For this, one+-- can use the combinator 'impossibleToNotTransfer' as the last argument to+-- 'allocateTemp'. allocateTemp :: (MonadSTM m, MonadMask m, MonadThread m, HasCallStack) => -- | Allocate the resource