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

Safe HaskellNone

Control.Monad.Trans.Resource.Internal

Synopsis

Documentation

newtype ExceptionT m a Source

The express purpose of this transformer is to allow non-IO-based monad stacks to catch exceptions via the MonadThrow typeclass.

Since 0.3.0

Constructors

ExceptionT 

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

functionName :: String
 

class (MonadThrow m, MonadUnsafeIO m, MonadIO m, Applicative m) => MonadResource m whereSource

A Monad which allows for safe resource allocation. In theory, any monad transformer stack included 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

Methods

liftResourceT :: ResourceT IO a -> m aSource

Lift a ResourceT IO action into the current Monad.

Since 0.4.0

class Monad m => MonadThrow m whereSource

A Monad which can throw exceptions. Note that this does not work in a vanilla ST or Identity monad. Instead, you should use the ExceptionT transformer in your stack if you are dealing with a non-IO base monad.

Since 0.3.0

Methods

monadThrow :: Exception e => e -> m aSource

class Monad m => MonadUnsafeIO m whereSource

A Monad based on some monad which allows running of some IO actions, via unsafe calls. This applies to IO and ST, for instance.

Since 0.3.0

Methods

unsafeLiftIO :: IO a -> m aSource

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 

Instances

data ReleaseMap Source

Constructors

ReleaseMap !NextKey !RefCount !(IntMap (IO ())) 
ReleaseMapClosed 

type ResIO a = ResourceT IO aSource

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

unResourceT :: IORef ReleaseMap -> m a
 

transResourceT :: (m a -> n b) -> ResourceT m a -> ResourceT n bSource

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