unliftio-0.1.1.0: The MonadUnliftIO typeclass for unlifting monads to IO (batteries included)

Safe Haskell | Safe
Language | Haskell2010

UnliftIO.Resource

Description

Unlifted Control.Monad.Trans.Resource.

Since: 0.1.0.0

Synopsis

- data ResourceT m a :: (* -> *) -> * -> *
- runResourceT :: MonadUnliftIO m => ResourceT m a -> m a
- liftResourceT :: MonadIO m => ResourceT IO a -> ResourceT m a

# Documentation

data ResourceT m a :: (* -> *) -> * -> * #

The Resource transformer. This transformer keeps track of all registered actions, and calls them upon exit (via `runResourceT`). Actions may be registered via `register`, or resources may be allocated atomically via `allocate`. `allocate` corresponds closely to `bracket`.

Releasing may be performed before exit via the `release` function. This is a highly recommended optimization, as it will ensure that scarce resources are freed early. Note that calling `release` will deregister the action, so that a release action will only ever be called once.

Since 0.3.0

Instances

MonadTrans ResourceT |
Methods lift :: Monad m => m a -> ResourceT m a #
MonadTransControl ResourceT |
Associated Types type StT (ResourceT :: (* -> *) -> * -> *) a :: * Methods liftWith :: Monad m => (Run ResourceT -> m a) -> ResourceT m a restoreT :: Monad m => m (StT ResourceT a) -> ResourceT m a
MMonad ResourceT | Since 0.4.7
Methods embed :: Monad n => (forall a. m a -> ResourceT n a) -> ResourceT m b -> ResourceT n b
MFunctor ResourceT | Since 0.4.7
Methods hoist :: Monad m => (forall a. m a -> n a) -> ResourceT m b -> ResourceT n b
MonadRWS r w s m => MonadRWS r w s (ResourceT m) |
MonadBaseControl b m => MonadBaseControl b (ResourceT m) |
Associated Types type StM (ResourceT m :: * -> *) a :: * Methods liftBaseWith :: (RunInBase (ResourceT m) b -> b a) -> ResourceT m a restoreM :: StM (ResourceT m) a -> ResourceT m a
MonadState s m => MonadState s (ResourceT m) |
Methods get :: ResourceT m s put :: s -> ResourceT m () state :: (s -> (a, s)) -> ResourceT m a
MonadWriter w m => MonadWriter w (ResourceT m) |
Methods writer :: (a, w) -> ResourceT m a tell :: w -> ResourceT m () listen :: ResourceT m a -> ResourceT m (a, w) pass :: ResourceT m (a, w -> w) -> ResourceT m a
MonadReader r m => MonadReader r (ResourceT m) |
Methods ask :: ResourceT m r local :: (r -> r) -> ResourceT m a -> ResourceT m a reader :: (r -> a) -> ResourceT m a
MonadError e m => MonadError e (ResourceT m) |
Methods throwError :: e -> ResourceT m a catchError :: ResourceT m a -> (e -> ResourceT m a) -> ResourceT m a
MonadBase b m => MonadBase b (ResourceT m) |
Methods liftBase :: b α -> ResourceT m α
Monad m => Monad (ResourceT m) |
Methods (>>=) :: ResourceT m a -> (a -> ResourceT m b) -> ResourceT m b # (>>) :: ResourceT m a -> ResourceT m b -> ResourceT m b # return :: a -> ResourceT m a # fail :: String -> ResourceT m a #
Functor m => Functor (ResourceT m) |
Methods fmap :: (a -> b) -> ResourceT m a -> ResourceT m b # (<$) :: a -> ResourceT m b -> ResourceT m a #
MonadFix m => MonadFix (ResourceT m) | Since: 1.1.8
Methods mfix :: (a -> ResourceT m a) -> ResourceT m a #
Applicative m => Applicative (ResourceT m) |
Methods pure :: a -> ResourceT m a # (<*>) :: ResourceT m (a -> b) -> ResourceT m a -> ResourceT m b # (*>) :: ResourceT m a -> ResourceT m b -> ResourceT m b # (<*) :: ResourceT m a -> ResourceT m b -> ResourceT m a #
MonadIO m => MonadIO (ResourceT m) |
Methods liftIO :: IO a -> ResourceT m a #
Alternative m => Alternative (ResourceT m) | Since 1.1.5
Methods empty :: ResourceT m a # (<|>) :: ResourceT m a -> ResourceT m a -> ResourceT m a # some :: ResourceT m a -> ResourceT m [a] # many :: ResourceT m a -> ResourceT m [a] #
MonadPlus m => MonadPlus (ResourceT m) | Since 1.1.5
Methods mzero :: ResourceT m a # mplus :: ResourceT m a -> ResourceT m a -> ResourceT m a #
MonadLogger m => MonadLogger (ResourceT m) |
Methods monadLoggerLog :: ToLogStr msg => Loc -> LogSource -> LogLevel -> msg -> ResourceT m () #
MonadLoggerIO m => MonadLoggerIO (ResourceT m) |
Methods askLoggerIO :: ResourceT m (Loc -> LogSource -> LogLevel -> LogStr -> IO ()) #
(MonadThrow m, MonadBase IO m, MonadIO m, Applicative m) => MonadResource (ResourceT m) |
Methods liftResourceT :: ResourceT IO a -> ResourceT m a #
MonadThrow m => MonadThrow (ResourceT m) |
Methods throwM :: Exception e => e -> ResourceT m a #
MonadMask m => MonadMask (ResourceT m) |
Methods mask :: ((forall a. ResourceT m a -> ResourceT m a) -> ResourceT m b) -> ResourceT m b uninterruptibleMask :: ((forall a. ResourceT m a -> ResourceT m a) -> ResourceT m b) -> ResourceT m b
MonadCont m => MonadCont (ResourceT m) |
Methods callCC :: ((a -> ResourceT m b) -> ResourceT m a) -> ResourceT m a
MonadCatch m => MonadCatch (ResourceT m) |
Methods catch :: Exception e => ResourceT m a -> (e -> ResourceT m a) -> ResourceT m a
type StT ResourceT a |
type StT ResourceT a = a
type StM (ResourceT m) a |
type StM (ResourceT m) a = StM m a

runResourceT :: MonadUnliftIO m => ResourceT m a -> m a Source #

Unlifted version of `runResourceT`.

Since: 0.1.0.0

liftResourceT :: MonadIO m => ResourceT IO a -> ResourceT m a Source #

Lifted version of `liftResourceT`.

Since: 0.1.0.0