- Prelude
- use <M, A> (K<M, A> acquire, Action<A> release)
- use <A> (Func<A> acquire, Action<A> release)
- use <A> (Func<A> acquire, Func<A, IO<Unit>> release)
- use <M, A> (K<M, A> acquire, Func<A, IO<Unit>> release)
- use <A> (Func<EnvIO, A> acquire)
- use <A> (Func<A> acquire)
- useAsync <A> (Func<A> acquire)
- use <M, A> (K<M, A> acquire)
- useAsync <M, A> (K<M, A> acquire)
- release <A> (A value)
- bracketIO <M, A> (K<M, A> computation)
- bracketIO <M, A, B, C> (K<M, A> Acq, Func<A, IO<C>> Use, Func<A, IO<B>> Fin)
method K<M, A> use <M, A> (K<M, A> acquire, Action<A> release) Source #
Acquire a resource and have it tracked by the IO environment. The resource
can be released manually using release
or from wrapping a section of IO
code with @using
.
type | A | Bound value type |
param | acquire | Computation that acquires the resource |
param | release | Action to release the resource |
returns | Acquired resource |
method IO<A> use <A> (Func<A> acquire, Action<A> release) Source #
Acquire a resource and have it tracked by the IO environment. The resource
can be released manually using release
or from wrapping a section of IO
code with @using
.
type | A | Bound value type |
param | acquire | Computation that acquires the resource |
param | release | Action to release the resource |
returns | Acquired resource |
method IO<A> use <A> (Func<A> acquire, Func<A, IO<Unit>> release) Source #
Acquire a resource and have it tracked by the IO environment. The resource
can be released manually using release
or from wrapping a section of IO
code with @using
.
type | A | Bound value type |
param | acquire | Computation that acquires the resource |
param | release | Action to release the resource |
returns | Acquired resource |
method K<M, A> use <M, A> (K<M, A> acquire, Func<A, IO<Unit>> release) Source #
Acquire a resource and have it tracked by the IO environment. The resource
can be released manually using release
or from wrapping a section of IO
code with @using
.
type | A | Bound value type |
param | acquire | Computation that acquires the resource |
param | release | Action to release the resource |
returns | Acquired resource |
method IO<A> use <A> (Func<EnvIO, A> acquire) Source #
Acquire a resource and have it tracked by the IO environment. The resource
can be released manually using release
or from wrapping a section of IO
code with @using
.
type | A | Bound value type |
param | acquire | Computation that acquires the resource |
returns | Acquired resource |
method IO<A> use <A> (Func<A> acquire) Source #
Acquire a resource and have it tracked by the IO environment. The resource
can be released manually using release
or from wrapping a section of IO
code with @using
.
type | A | Bound value type |
param | acquire | Computation that acquires the resource |
returns | Acquired resource |
method IO<A> useAsync <A> (Func<A> acquire) Source #
Acquire a resource and have it tracked by the IO environment. The resource
can be released manually using release
or from wrapping a section of IO
code with @using
.
type | A | Bound value type |
param | acquire | Computation that acquires the resource |
returns | Acquired resource |
method K<M, A> use <M, A> (K<M, A> acquire) Source #
Acquire a resource and have it tracked by the IO environment. The resource
can be released manually using release
or from wrapping a section of IO
code with @using
.
type | A | Bound value type |
param | acquire | Computation that acquires the resource |
returns | Acquired resource |
method K<M, A> useAsync <M, A> (K<M, A> acquire) Source #
Acquire a resource and have it tracked by the IO environment. The resource
can be released manually using release
or from wrapping a section of IO
code with @using
.
type | A | Bound value type |
param | acquire | Computation that acquires the resource |
returns | Acquired resource |
method IO<Unit> release <A> (A value) Source #
Release the resource from the tracked IO environment
type | A | Bound value type |
param | value | Resource to release |
returns | Unit |
method K<M, A> bracketIO <M, A> (K<M, A> computation) Source #
The IO monad tracks resources automatically, this creates a local resource environment
to run the computation
in. Once the computation has completed any resources acquired
are automatically released. Imagine this as the ultimate using
statement.
type | A | Bound value type |
param | computation | Computation to run in a local scope |
returns | Result of computation |
method K<M, C> bracketIO <M, A, B, C> (K<M, A> Acq, Func<A, IO<C>> Use, Func<A, IO<B>> Fin) Source #
When acquiring, using, and releasing various resources, it can be quite convenient to write a function to manage the acquisition and releasing, taking a function of the acquired value that specifies an action to be performed in between.
Consider using bracketIO(computation)
rather than bracket(acq, use, fin)
, the semantics are more attractive
as there's no need to provide function handlers, the cleanup is automatic.
param | Acq | Acquire resource |
param | Use | Function to use the acquired resource |
param | Fin | Function to invoke to release the resource |