managed-1.0.0: A monad for managed values

Safe HaskellSafe-Inferred

Control.Monad.Managed.Safe

Contents

Description

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.

Synopsis

Managed

data Managed a Source

A managed resource that you acquire using with

managed :: (forall r. (a -> IO r) -> IO r) -> Managed aSource

Build a Managed value

runManaged :: Managed () -> IO ()Source

Run a Managed computation, enforcing that no acquired resources leak

Re-exports