Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- mkAcquire1 :: IO a -> (a -> IO ()) -> Acquire a
- mkAcquireType1 :: IO a -> (a -> ReleaseType -> IO ()) -> Acquire a
- acquireReleaseSelf :: Acquire ((ReleaseType -> IO ()) -> a) -> Acquire a
- registerType :: MonadResource m => (ReleaseType -> IO ()) -> m ReleaseKey
- releaseType :: MonadIO m => ReleaseKey -> ReleaseType -> m ()
- unprotectType :: MonadIO m => ReleaseKey -> m (Maybe (ReleaseType -> IO ()))
- acquireReleaseKey :: ReleaseKey -> Acquire ()
- runResourceT :: (MonadMask m, MonadIO m) => ResourceT m a -> m a
- withAcquire :: (MonadMask m, MonadIO m) => Acquire a -> (a -> m b) -> m b
- withAcquireRelease :: (MonadMask m, MonadIO m) => Acquire a -> ((ReleaseType -> IO ()) -> a -> m b) -> m b
- newtype Restore m = Restore (forall x. m x -> m x)
- getRestoreIO :: MonadIO m => m (Restore IO)
- withRestoreIO :: (MonadMask m, MonadIO m) => ((forall x. IO x -> IO x) -> m a) -> m a
- asyncRestore :: MonadUnliftIO m => Bool -> ((forall x. IO x -> IO x) -> ResourceT m a) -> ResourceT m (ReleaseKey, Async a)
- once :: (MonadIO m, MonadIO n, MonadMask n) => n () -> m (n ())
- onceK :: (MonadIO m, MonadIO n, MonadMask n) => (a -> n ()) -> m (a -> n ())
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
registerType :: MonadResource m => (ReleaseType -> IO ()) -> m ReleaseKey Source #
Like register
, but gives access to the ReleaseType
too.
releaseType :: MonadIO m => ReleaseKey -> ReleaseType -> m () Source #
Like release
, but allows specifying the ReleaseType
too.
unprotectType :: MonadIO m => ReleaseKey -> m (Maybe (ReleaseType -> IO ())) Source #
acquireReleaseKey :: ReleaseKey -> Acquire () Source #
acquireReleaseKey
will unprotectType
the ReleaseKey
,
and use Acquire
to manage the release action instead.
MonadMask
runResourceT :: (MonadMask m, MonadIO m) => ResourceT m a -> m a Source #
Like runResourceT
, but requires only 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 #
acquires the withAcquireRelease
acq \release a -> acta
and
automaticaly releases it when mb
returns or throws an exception.
If desired, release
can be used to release a
earlier.
Restore
Wrapper around a “restore” function like the one given
by
, in a particular mask
(\restore -> ...)Monad
m
.
Restore (forall x. m x -> m x) |
Async
:: MonadUnliftIO m | |
=> Bool | |
-> ((forall x. IO x -> IO x) -> ResourceT m a) | |
-> ResourceT m (ReleaseKey, Async a) |
IO
once :: (MonadIO m, MonadIO n, MonadMask n) => n () -> m (n ()) Source #
creates a wrapper for once
mama
which will execute ma
at most
once. Further executions of the same wrapped ma
are a no-op. It's safe to
attempt to use the wrapper concurrently; only one thread will get to execute
the actual ma
at most.