resourcet-extra-0.0.1: ResourceT extras
Safe HaskellSafe-Inferred
LanguageGHC2021

Control.Monad.Trans.Resource.Extra

Synopsis

Acquire

mkAcquire1 :: IO a -> (a -> IO ()) -> Acquire a Source #

Like mkAcquire, but the release function will be run at most once.

mkAcquireType1 :: IO a -> (a -> ReleaseType -> IO ()) -> Acquire a Source #

Like mkAcquireType, but the release function will be run at most once.

acquireReleaseSelf :: Acquire ((ReleaseType -> IO ()) -> a) -> Acquire a Source #

Build an Acquire having access to its own release function.

MonadResource

acquireReleaseKey :: ReleaseKey -> Acquire () Source #

acquireReleaseKey will unprotect the ReleaseKey, and use Acquire to manage the release action instead.

registerType :: MonadResource m => (ReleaseType -> IO ()) -> m ReleaseKey Source #

Like register, but gives access to the ReleaseType too.

MonadMask

withAcquire :: (MonadMask m, MonadIO m) => Acquire a -> (a -> m b) -> m b Source #

Like withAcquireRelease, but doesn't take the extra release function.

withAcquireRelease :: (MonadMask m, MonadIO m) => Acquire a -> ((ReleaseType -> IO ()) -> a -> m b) -> m b Source #

withAcquireRelease acq \release a -> act acquires the a and automaticaly releases it when mb returns or throws an exception. If desired, release can be used to release a earlier.

Restore

newtype Restore m Source #

Wrapper around a “restore” function like the one given by mask (\restore -> ...), in a particular Monad m.

Constructors

Restore (forall x. m x -> m x) 

getRestoreIO :: MonadIO m => m (Restore IO) Source #

Get the current Restore action in IO, wrapped in Restore.

withRestoreIO :: (MonadMask m, MonadIO m) => ((forall x. IO x -> IO x) -> m a) -> m a Source #

Get the current Restore action in IO, without the Restore wrapper.

IO

once :: (MonadIO m, MonadMask m) => m () -> m () Source #

once ma wraps ma so that ma is executed at most once. Further executions of the same once ma are a no-op. It's safe to use the wrapper concurrently; only one thread will get to execute the actual ma at most.

onceK :: (MonadIO m, MonadMask m) => (a -> m ()) -> a -> m () Source #

Kleisli version of once.