Safe Haskell | Safe |
---|---|
Language | Haskell98 |
This module is a safer subset of Control.Monad.Managed that only lets you
unwrap the Managed
type using runManaged
. This enforces that you never
leak acquired resources from a Managed
computation.
In general, you should strive to propagate the Managed
type as much as
possible and use runManaged
when you are done with acquired resources.
However, there are legitimate circumstances where you want to return a value
other than acquired resource from the bracketed computation, which requires
using with
.
This module is not the default because you can also use the Managed
type
for callback-based code that is completely unrelated to resources.
Managed
A managed resource that you acquire using with
class MonadIO m => MonadManaged m where Source
You can embed a Managed
action within any Monad
that implements
MonadManaged
by using the using
function
All instances must obey the following two laws:
using (return x) = return x using (m >>= f) = using m >>= \x -> using (f x)
MonadManaged Managed Source | |
MonadManaged m => MonadManaged (MaybeT m) Source | |
MonadManaged m => MonadManaged (IdentityT m) Source | |
(Monoid w, MonadManaged m) => MonadManaged (WriterT w m) Source | |
(Monoid w, MonadManaged m) => MonadManaged (WriterT w m) Source | |
MonadManaged m => MonadManaged (ExceptT e m) Source | |
MonadManaged m => MonadManaged (StateT s m) Source | |
MonadManaged m => MonadManaged (StateT s m) Source | |
MonadManaged m => MonadManaged (ReaderT r m) Source | |
MonadManaged m => MonadManaged (ContT r m) Source | |
(Monoid w, MonadManaged m) => MonadManaged (RWST r w s m) Source | |
(Monoid w, MonadManaged m) => MonadManaged (RWST r w s m) Source |
managed_ :: (forall r. IO r -> IO r) -> Managed () Source
Like managed
but for resource-less operations.
runManaged :: Managed () -> IO () Source
Run a Managed
computation, enforcing that no acquired resources leak
Re-exports
Control.Monad.IO.Class re-exports MonadIO
module Control.Monad.IO.Class