diff --git a/src/Quasar/Disposable.hs b/src/Quasar/Disposable.hs index 29d929124c91282f01e14f0ba839e12bdd1078d8..250abb5ae67868fe587638fb6437b58fa781e0af 100644 --- a/src/Quasar/Disposable.hs +++ b/src/Quasar/Disposable.hs @@ -10,11 +10,12 @@ module Quasar.Disposable ( -- ** ResourceManager ResourceManager, HasResourceManager(..), + withResourceManager, newResourceManager, - disposeEventually, attachDisposable, attachDisposeAction, attachDisposeAction_, + disposeEventually, ) where import Control.Concurrent.STM @@ -135,6 +136,9 @@ class HasResourceManager a where instance IsDisposable ResourceManager where toDisposable = undefined +withResourceManager :: (ResourceManager -> IO a) -> IO a +withResourceManager = bracket newResourceManager (awaitIO <=< dispose) + newResourceManager :: IO ResourceManager newResourceManager = pure ResourceManager