std.disposable

Modules

A Disposable abstracts over different kinds of resources.

Types

type Disposable a = { dispose : a -> IO (), is_disposed : a -> std.types.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 . [std.disposable.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 . [std.disposable.Disposable a] -> a -> std.types.Bool

Indicates if a has been disposed, meaning that dispose has been called at least once.

let using disposable action : forall a . forall r . [std.disposable.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.