LanguageExt.Core

LanguageExt.Core Prelude Resources

Contents

class Prelude Source #

Methods

method K<M, A> use <M, A> (K<M, A> acquire, Action<A> release) Source #

where M : Monad<M>

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 bracketIO.

Parameters

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.

Parameters

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.

Parameters

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 #

where M : Monad<M>

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.

Parameters

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 #

where A : IDisposable

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.

Parameters

type A

Bound value type

param acquire

Computation that acquires the resource

returns

Acquired resource

method IO<A> use <A> (Func<A> acquire) Source #

where A : IDisposable

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.

Parameters

type A

Bound value type

param acquire

Computation that acquires the resource

returns

Acquired resource

method IO<A> useAsync <A> (Func<A> acquire) Source #

where A : IAsyncDisposable

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.

Parameters

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 #

where M : Monad<M>
where A : IDisposable

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.

Parameters

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 #

where M : Monad<M>
where A : IAsyncDisposable

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.

Parameters

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

Parameters

type A

Bound value type

param value

Resource to release

returns

Unit

method K<M, A> bracketIO <M, A> (K<M, A> computation) Source #

where M : Monad<M>

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.

Parameters

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 #

where M : Monad<M>

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.

Parameters

param Acq

Acquire resource

param Use

Function to use the acquired resource

param Fin

Function to invoke to release the resource

method K<M, C> bracketIO <M, A, B, C> (K<M, A> Acq, Func<A, IO<C>> Use, Func<Error, IO<C>> Catch, Func<A, IO<B>> Fin) Source #

where M : Monad<M>

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.

Parameters

param Acq

Acquire resource

param Use

Function to use the acquired resource

param Catch

Function called when an Error is raised within the Acq computation

param Finally

Function to invoke to release the resource