Stability | experimental |
---|---|
Maintainer | tomac `at` pacific `dot` net `dot` au |
Resource management in the IOR monad.
Documentation
wraps a resource of type Resource
r aa
so it can be managed
inside region r
and automatically released upon exit from r
.
getResource :: Resource r a -> aSource
Extract a
from the Resource
wrapper.
manage :: a -> (a -> IO ()) -> IOR r rs (Resource r a)Source
will create a new manage
a fResource
wrapper around the
value of type a
in region r
, given a finalizer f
.
Each finalizer is guaranteed to automatically be called upon exit from
the region.
Finalizers are called in the last in, first out fashion. So the finalizer
of the very last resource allocated will be the first to get called.
Note that finalizers must not throw any errors. Failing to ensure that all errors in a finalizer are handled may result in a resource leak.