| Safe Haskell | None | 
|---|---|
| Language | Haskell98 | 
Control.Monad.Trans.Resource.Internal
Synopsis
- data InvalidAccess = InvalidAccess {}
- class MonadIO m => MonadResource m where- liftResourceT :: ResourceT IO a -> m a
 
- data ReleaseKey = ReleaseKey !(IORef ReleaseMap) !Int
- data ReleaseMap- = ReleaseMap !NextKey !RefCount !(IntMap (ReleaseType -> IO ()))
- | ReleaseMapClosed
 
- type ResIO = ResourceT IO
- newtype ResourceT m a = ResourceT {- unResourceT :: IORef ReleaseMap -> m a
 
- stateAlloc :: IORef ReleaseMap -> IO ()
- stateCleanup :: ReleaseType -> IORef ReleaseMap -> IO ()
- transResourceT :: (m a -> n b) -> ResourceT m a -> ResourceT n b
- register' :: IORef ReleaseMap -> IO () -> IO ReleaseKey
- registerType :: IORef ReleaseMap -> (ReleaseType -> IO ()) -> IO ReleaseKey
- data ResourceCleanupException = ResourceCleanupException {}
- stateCleanupChecked :: Maybe SomeException -> IORef ReleaseMap -> IO ()
Documentation
data InvalidAccess #
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 | |
Instances
| Show InvalidAccess # | |
| Defined in Control.Monad.Trans.Resource.Internal Methods showsPrec :: Int -> InvalidAccess -> ShowS # show :: InvalidAccess -> String # showList :: [InvalidAccess] -> ShowS # | |
| Exception InvalidAccess # | |
| Defined in Control.Monad.Trans.Resource.Internal Methods toException :: InvalidAccess -> SomeException # fromException :: SomeException -> Maybe InvalidAccess # displayException :: InvalidAccess -> String # | |
class MonadIO m => MonadResource m where #
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 MonadUnliftIO 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 a #
Lift a ResourceT IO action into the current Monad.
Since 0.4.0
Instances
data ReleaseKey #
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 #
Constructors
| ReleaseMap !NextKey !RefCount !(IntMap (ReleaseType -> IO ())) | |
| ReleaseMapClosed | 
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
stateAlloc :: IORef ReleaseMap -> IO () #
stateCleanup :: ReleaseType -> IORef ReleaseMap -> IO () #
transResourceT :: (m a -> n b) -> ResourceT m a -> ResourceT n b #
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
register' :: IORef ReleaseMap -> IO () -> IO ReleaseKey #
registerType :: IORef ReleaseMap -> (ReleaseType -> IO ()) -> IO ReleaseKey #
Since 1.1.2
data ResourceCleanupException #
Thrown when one or more cleanup functions themselves throw an exception during cleanup.
Since: 1.1.11
Constructors
| ResourceCleanupException | |
| Fields 
 | |
Instances
| Show ResourceCleanupException # | |
| Defined in Control.Monad.Trans.Resource.Internal Methods showsPrec :: Int -> ResourceCleanupException -> ShowS # show :: ResourceCleanupException -> String # showList :: [ResourceCleanupException] -> ShowS # | |
| Exception ResourceCleanupException # | |
Arguments
| :: Maybe SomeException | exception that killed the  | 
| -> IORef ReleaseMap | |
| -> IO () | 
Clean up a release map, but throw a ResourceCleanupException if
 anything goes wrong in the cleanup handlers.
Since: 1.1.11