resourcet-1.1.8: Deterministic allocation and freeing of scarce resources.

Safe HaskellSafe
LanguageHaskell98

Control.Monad.Trans.Resource.Internal

Synopsis

Documentation

data InvalidAccess Source #

Indicates either an error in the library, or misuse of it (e.g., a ResourceT's state is accessed after being released).

Since 0.3.0

Constructors

InvalidAccess 

Fields

class (MonadThrow m, MonadIO m, Applicative m, MonadBase IO m) => MonadResource m where Source #

A Monad which allows for safe resource allocation. In theory, any monad transformer stack which includes a ResourceT can be an instance of MonadResource.

Note: runResourceT has a requirement for a MonadBaseControl IO m monad, which allows control operations to be lifted. A MonadResource does not have this requirement. This means that transformers such as ContT can be an instance of MonadResource. However, the ContT wrapper will need to be unwrapped before calling runResourceT.

Since 0.3.0

Minimal complete definition

liftResourceT

Methods

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

Lift a ResourceT IO action into the current Monad.

Since 0.4.0

Instances

MonadResource m => MonadResource (ListT m) Source # 

Methods

liftResourceT :: ResourceT IO a -> ListT m a Source #

MonadResource m => MonadResource (MaybeT m) Source # 
(MonadThrow m, MonadBase IO m, MonadIO m, Applicative m) => MonadResource (ResourceT m) Source # 
MonadResource m => MonadResource (ExceptT e m) Source # 

Methods

liftResourceT :: ResourceT IO a -> ExceptT e m a Source #

(Error e, MonadResource m) => MonadResource (ErrorT e m) Source # 

Methods

liftResourceT :: ResourceT IO a -> ErrorT e m a Source #

MonadResource m => MonadResource (StateT s m) Source # 

Methods

liftResourceT :: ResourceT IO a -> StateT s m a Source #

MonadResource m => MonadResource (StateT s m) Source # 

Methods

liftResourceT :: ResourceT IO a -> StateT s m a Source #

(Monoid w, MonadResource m) => MonadResource (WriterT w m) Source # 

Methods

liftResourceT :: ResourceT IO a -> WriterT w m a Source #

(Monoid w, MonadResource m) => MonadResource (WriterT w m) Source # 

Methods

liftResourceT :: ResourceT IO a -> WriterT w m a Source #

MonadResource m => MonadResource (IdentityT * m) Source # 
MonadResource m => MonadResource (ContT * r m) Source # 

Methods

liftResourceT :: ResourceT IO a -> ContT * r m a Source #

MonadResource m => MonadResource (ReaderT * r m) Source # 

Methods

liftResourceT :: ResourceT IO a -> ReaderT * r m a Source #

(Monoid w, MonadResource m) => MonadResource (RWST r w s m) Source # 

Methods

liftResourceT :: ResourceT IO a -> RWST r w s m a Source #

(Monoid w, MonadResource m) => MonadResource (RWST r w s m) Source # 

Methods

liftResourceT :: ResourceT IO a -> RWST r w s m a Source #

data ReleaseKey Source #

A lookup key for a specific release action. This value is returned by register and allocate, and is passed to release.

Since 0.3.0

Constructors

ReleaseKey !(IORef ReleaseMap) !Int 

data ReleaseMap Source #

Constructors

ReleaseMap !NextKey !RefCount !(IntMap (ReleaseType -> IO ())) 
ReleaseMapClosed 

type ResIO a = ResourceT IO a Source #

Convenient alias for ResourceT IO.

newtype ResourceT m a Source #

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

Constructors

ResourceT 

Fields

Instances

MFunctor ResourceT Source #

Since 0.4.7

Methods

hoist :: Monad m => (forall a. m a -> n a) -> ResourceT m b -> ResourceT n b #

MMonad ResourceT Source #

Since 0.4.7

Methods

embed :: Monad n => (forall a. m a -> ResourceT n a) -> ResourceT m b -> ResourceT n b #

MonadTrans ResourceT Source # 

Methods

lift :: Monad m => m a -> ResourceT m a #

MonadTransControl ResourceT Source # 

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 #

MonadRWS r w s m => MonadRWS r w s (ResourceT m) Source # 
MonadBase b m => MonadBase b (ResourceT m) Source # 

Methods

liftBase :: b α -> ResourceT m α #

MonadBaseControl b m => MonadBaseControl b (ResourceT m) Source # 

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 #

MonadError e m => MonadError e (ResourceT m) Source # 

Methods

throwError :: e -> ResourceT m a #

catchError :: ResourceT m a -> (e -> ResourceT m a) -> ResourceT m a #

MonadReader r m => MonadReader r (ResourceT m) Source # 

Methods

ask :: ResourceT m r #

local :: (r -> r) -> ResourceT m a -> ResourceT m a #

reader :: (r -> a) -> ResourceT m a #

MonadState s m => MonadState s (ResourceT m) Source # 

Methods

get :: ResourceT m s #

put :: s -> ResourceT m () #

state :: (s -> (a, s)) -> ResourceT m a #

MonadWriter w m => MonadWriter w (ResourceT m) Source # 

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 #

Monad m => Monad (ResourceT m) Source # 

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) Source # 

Methods

fmap :: (a -> b) -> ResourceT m a -> ResourceT m b #

(<$) :: a -> ResourceT m b -> ResourceT m a #

MonadFix m => MonadFix (ResourceT m) Source #

Since: 1.1.8

Methods

mfix :: (a -> ResourceT m a) -> ResourceT m a #

Applicative m => Applicative (ResourceT m) Source # 

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) Source # 

Methods

liftIO :: IO a -> ResourceT m a #

Alternative m => Alternative (ResourceT m) Source #

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) Source #

Since 1.1.5

Methods

mzero :: ResourceT m a #

mplus :: ResourceT m a -> ResourceT m a -> ResourceT m a #

MonadThrow m => MonadThrow (ResourceT m) Source # 

Methods

throwM :: Exception e => e -> ResourceT m a #

MonadCatch m => MonadCatch (ResourceT m) Source # 

Methods

catch :: Exception e => ResourceT m a -> (e -> ResourceT m a) -> ResourceT m a #

MonadMask m => MonadMask (ResourceT m) Source # 

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) Source # 

Methods

callCC :: ((a -> ResourceT m b) -> ResourceT m a) -> ResourceT m a #

(MonadThrow m, MonadBase IO m, MonadIO m, Applicative m) => MonadResource (ResourceT m) Source # 
type StT ResourceT a Source # 
type StT ResourceT a = a
type StM (ResourceT m) a Source # 
type StM (ResourceT m) a = StM m a

transResourceT :: (m a -> n b) -> ResourceT m a -> ResourceT n b Source #

Transform the monad a ResourceT lives in. This is most often used to strip or add new transformers to a stack, e.g. to run a ReaderT.

Note that this function is a slight generalization of hoist.

Since 0.3.0