LanguageExt.Core

LanguageExt.Core Type Classes FoldableAsync

Contents

interface FoldableAsync <FA, A> Source #

interface FoldableAsync <Env, FA, A> Source #

class TypeClass Source #

Methods

method Task<S> foldAsync <FOLD, F, A, S> (F fa, S state, Func<S, A, S> f) Source #

where FOLD : FoldableAsync<F, A>

In the case of lists, 'Fold', when applied to a binary operator, a starting value(typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right.

Note that, since the head of the resulting expression is produced by an application of the operator to the first element of the list, 'Fold' can produce a terminating expression from an infinite list.

Parameters

type S

Aggregate state type

param state

Initial state

param f

Folder function, applied for each item in fa

returns

The aggregate state

method Task<S> foldAsync <FOLD, F, A, S> (F fa, S state, Func<S, A, Task<S>> f) Source #

where FOLD : FoldableAsync<F, A>

In the case of lists, 'Fold', when applied to a binary operator, a starting value(typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right.

Note that, since the head of the resulting expression is produced by an application of the operator to the first element of the list, 'Fold' can produce a terminating expression from an infinite list.

Parameters

type S

Aggregate state type

param state

Initial state

param f

Folder function, applied for each item in fa

returns

The aggregate state

method Task<S> foldBackAsync <FOLD, F, A, S> (F fa, S state, Func<S, A, S> f) Source #

where FOLD : FoldableAsync<F, A>

In the case of lists, 'FoldBack', when applied to a binary operator, a starting value(typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right.

Note that to produce the outermost application of the operator the entire input list must be traversed.

Parameters

type S

Aggregate state type

param state

Initial state

param f

Folder function, applied for each item in fa

returns

The aggregate state

method Task<S> foldBackAsync <FOLD, F, A, S> (F fa, S state, Func<S, A, Task<S>> f) Source #

where FOLD : FoldableAsync<F, A>

In the case of lists, 'FoldBack', when applied to a binary operator, a starting value(typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right.

Note that to produce the outermost application of the operator the entire input list must be traversed.

Parameters

type S

Aggregate state type

param state

Initial state

param f

Folder function, applied for each item in fa

returns

The aggregate state

method Task<Unit> iterAsync <FOLD, F, A> (F fa, Action<A> action) Source #

where FOLD : FoldableAsync<F, A>

Iterate the values in the foldable

Parameters

type A

Bound value type

param self

Foldable to perform the operation on

method Task<Unit> iterAsync <FOLD, F, A> (F fa, Func<A, Task<Unit>> action) Source #

where FOLD : FoldableAsync<F, A>

Iterate the values in the foldable

Parameters

type A

Bound value type

param self

Foldable to perform the operation on

method Task<Seq<A>> toSeqAsync <FOLD, F, A> (F fa) Source #

where FOLD : FoldableAsync<F, A>

Turn any foldable into a sequence

Parameters

type A

Sequence item type

param fa

Foldable

returns

Sequence of As

method Task<IEnumerable<B>> collectAsync <FOLD, F, A, B> (F self, Func<A, B> f) Source #

where FOLD : FoldableAsync<F, A>

Convert the foldable to a sequence (IEnumerable) performing a map operation on each item in the structure

Parameters

type A

Bound value type

param self

Foldable to performt the operation on

returns

Sequence of As that represent the value(s) in the structure

method Task<A> headAsync <FOLD, F, A> (F fa) Source #

where FOLD : FoldableAsync<F, A>

Get the first item in a foldable structure

Parameters

type A

Sequence item type

param fa

Foldable

returns

First A produced by the foldable

method Task<Option<A>> headOrNoneAsync <FOLD, F, A> (F fa) Source #

where FOLD : FoldableAsync<F, A>

Get the first item in a foldable structure

Parameters

type A

Sequence item type

param fa

Foldable

returns

First A produced by the foldable (Or None if no items produced)

method Task<Validation<FAIL, A>> headOrInvalidAsync <FOLD, F, FAIL, A> (F fa, FAIL fail) Source #

where FOLD : FoldableAsync<F, A>

Get the first item in a foldable structure

Parameters

type A

Sequence item type

param fa

Foldable

param fail

Fail case

returns

First A produced by the foldable (Or Fail if no items produced)

method Task<Either<L, A>> headOrLeftAsync <FOLD, F, L, A> (F fa, L left) Source #

where FOLD : FoldableAsync<F, A>

Get the first item in a foldable structure

Parameters

type A

Sequence item type

param fa

Foldable

param left

Left case

returns

First A produced by the foldable (Or Left if no items produced)

method Task<A> lastAsync <FOLD, F, A> (F fa) Source #

where FOLD : FoldableAsync<F, A>

Get the last item in a foldable structure

Parameters

type A

Sequence item type

param fa

Foldable

returns

Last A produced by the foldable

method Task<Option<A>> lastOrNoneAsync <FOLD, F, A> (F fa) Source #

where FOLD : FoldableAsync<F, A>

Get the last item in a foldable structure

Parameters

type A

Sequence item type

param fa

Foldable

returns

Last A produced by the foldable (Or None if no items produced)

method Task<bool> isEmptyAsync <FOLD, F, A> (F fa) Source #

where FOLD : FoldableAsync<F, A>

Tests whether the foldable structure is empty

Parameters

type A

Foldable item type

param fa

Foldable

returns

True if empty, False otherwise

method Task<int> countAsync <FOLD, F, A> (F fa) Source #

where FOLD : FoldableAsync<F, A>

Find the length of a foldable structure

Parameters

type A

Foldable item type

param fa

Foldable

returns

True if empty, False otherwise

method Task<bool> containsAsync <EQ, FOLD, F, A> (F fa, A item) Source #

where EQ : struct, Eq<A>
where FOLD : FoldableAsync<F, A>

Does the element occur in the structure?

Parameters

type EQ

Eq type-class

type A

Foldable item type

param fa

Foldable

param item

Item to test

returns

True if item in the structure

method Task<A> sumAsync <NUM, FOLD, F, A> (F fa) Source #

where FOLD : FoldableAsync<F, A>
where NUM : struct, Num<A>

The 'sum' function computes the sum of the numbers of a structure.

Parameters

type A

Foldable item type

returns

Sum of the numbers in the structure

method Task<A> productAsync <NUM, FOLD, F, A> (F fa) Source #

where FOLD : FoldableAsync<F, A>
where NUM : struct, Num<A>

The 'product' function computes the product of the numbers of a structure.

Parameters

type NUM

Foldable && NUM type

type A

Foldable item type

returns

Product of the numbers in the structure

method Task<bool> forallAsync <FOLD, F, A> (F fa, Func<A,bool> pred) Source #

where FOLD : FoldableAsync<F, A>

Runs a predicate against the bound value(s). If the predicate holds for all values then true is returned.

NOTE: An empty structure will return true.

Parameters

param pred

Predicate to apply

returns

True if the predicate holds for all values

method Task<bool> forallAsync <FOLD, F, A> (F fa, Func<A, Task<bool>> pred) Source #

where FOLD : FoldableAsync<F, A>

Runs a predicate against the bound value(s). If the predicate holds for all values then true is returned.

NOTE: An empty structure will return true.

Parameters

param pred

Predicate to apply

returns

True if the predicate holds for all values

method Task<bool> existsAsync <FOLD, F, A> (F fa, Func<A, bool> pred) Source #

where FOLD : FoldableAsync<F, A>

Runs a predicate against the bound value(s). If the predicate returns true for any item then the operation immediately returns true. False is returned if no items in the structure match the predicate.

NOTE: An empty structure will return false.

Parameters

param pred

Predicate to apply

returns

True if the predicate holds for all values

method Task<bool> existsAsync <FOLD, F, A> (F fa, Func<A, Task<bool>> pred) Source #

where FOLD : FoldableAsync<F, A>

Runs a predicate against the bound value(s). If the predicate returns true for any item then the operation immediately returns true. False is returned if no items in the structure match the predicate.

NOTE: An empty structure will return false.

Parameters

param pred

Predicate to apply

returns

True if the predicate holds for all values