std.disposable
A Disposable
abstracts over different kinds of resources.
Types
#[implicit]
type Disposable a = { dispose : a -> IO (), is_disposed : a -> Bool }
A resource that has to be released after use, for example a file handle or a database connection.
Values
let dispose ?disposable : forall a . [Disposable a] -> a -> IO ()
Disposes of a
, releasing the resources it manages. Calling this function
a second time (or more) has no effect.
let is_disposed ?disposable : forall a . [Disposable a] -> a -> Bool
Indicates if a
has been disposed, meaning that dispose
has been called
at least once.
let using disposable action : forall a . forall r . [Disposable a] -> a -> (a -> IO r) -> IO r
Calls action
with disposable
and disposes disposable
afterwards. Returns
the result of action
, unless disposing disposable
fails.