Skip to content

Commit 1588c09

Browse files
Add an acquire_ API
For allocating without a manual release.
1 parent 745f742 commit 1588c09

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

core/src/Streamly/Internal/Control/Exception.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ module Streamly.Internal.Control.Exception
3131
, withAcquireIO
3232
, acquireWith
3333
, acquire
34+
, acquire_
3435
, registerWith
3536
, register
3637
, hook
@@ -302,6 +303,11 @@ acquireWith pri (AcquireIO f) = f pri
302303
acquire :: AcquireIO -> IO b -> (b -> IO c) -> IO (b, IO ())
303304
acquire = acquireWith Priority2
304305

306+
-- | Like 'acquire' but does not return a release action. The resource is freed
307+
-- automatically only.
308+
acquire_ :: AcquireIO -> IO b -> (b -> IO c) -> IO b
309+
acquire_ a b c = fmap fst $ acquire a b c
310+
305311
-- | Like 'register' but specifies a 'Priority' for calling the hook.
306312
{-# INLINE registerWith #-}
307313
registerWith :: Priority -> AcquireIO -> IO () -> IO ()

0 commit comments

Comments
 (0)