Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- acquire1 :: ((forall x. IO x -> IO x) -> IO a) -> (a -> IO ()) -> Acquire a
- acquireType1 :: ((forall x. IO x -> IO x) -> IO a) -> (a -> ReleaseType -> IO ()) -> Acquire a
- mkAcquire1 :: IO a -> (a -> IO ()) -> Acquire a
- mkAcquireType1 :: IO a -> (a -> ReleaseType -> IO ()) -> Acquire a
- acquireReleaseSelf :: Acquire ((ReleaseType -> IO ()) -> a) -> Acquire a
- unAcquire :: MonadIO m => Acquire a -> (forall x. IO x -> IO x) -> m (a, ReleaseType -> IO ())
- 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
acquire1 :: ((forall x. IO x -> IO x) -> IO a) -> (a -> IO ()) -> Acquire a Source #
Like mkAcquire1
, but the acquire function is provided the current
Restore
-like function.
acquireType1 :: ((forall x. IO x -> IO x) -> IO a) -> (a -> ReleaseType -> IO ()) -> Acquire a Source #
Like mkAcquireType1
, but the acquire function is provided the current
Restore
-like function.
mkAcquire1 :: IO a -> (a -> IO ()) -> Acquire a Source #
Like mkAcquire
, but the release function will be run at most once.
Subsequent executions of the release function will be no-ops.
mkAcquireType1 :: IO a -> (a -> ReleaseType -> IO ()) -> Acquire a Source #
Like mkAcquireType
, but the release function will be run at most once.
Subsequent executions of the release function will be no-ops.
acquireReleaseSelf :: Acquire ((ReleaseType -> IO ()) -> a) -> Acquire a Source #
Build an Acquire
having access to its own release function.
The release function will be run at most once. Subsequent executions of the release function will be no-ops.
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 #
Like unprotect
, but allows specifying the ReleaseType
too.
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.