LanguageExt.Core

LanguageExt.Core Traits Traversable

Traversable structures support element-wise sequencing of Applicative effects (thus also Monad effects) to construct new structures of the same shape as the input.

To illustrate what is meant by same shape, if the input structure is [a], each output structure is a list [b] of the same length as the input. If the input is a Tree<A>, each output Tree<B> has the same graph of intermediate nodes and leaves. Similarly, if the input is a tuple (x, a), each output is a tuple (x, b), and so forth.

Every Traversable structure is both a Functor and Foldable.

Contents

class TraversableExtensions Source #

Functors representing data structures that can be transformed to structures of the same shape by performing an Applicative (or, therefore, Monad) action on each element from left to right.

A more detailed description of what same shape means, the various methods, how traversals are constructed, and example advanced use-cases can be found in the Overview section of Data.Traversable.

Parameters

type T

Methods

method K<F, K<T, B>> Traverse <T, F, A, B> ( this K<T, A> ta, Func<A, K<F, B>> f) Source #

where T : Traversable<T>
where F : Applicative<F>

method K<F, K<T, A>> Sequence <T, F, A> ( this K<T, K<F, A>> ta) Source #

where T : Traversable<T>
where F : Applicative<F>

method K<M, K<T, B>> TraverseM <M, T, A, B> ( this Func<A, K<M, B>> f, K<T, A> ta) Source #

where T : Traversable<T>
where M : Monad<M>

method K<F, K<T, A>> SequenceM <T, F, A> ( this K<T, K<F, A>> ta) Source #

where T : Traversable<T>
where F : Monad<F>

class Traversable Source #

Methods

method K<F, K<T, B>> traverse <T, F, A, B> ( Func<A, K<F, B>> f, K<T, A> ta) Source #

where T : Traversable<T>
where F : Applicative<F>

Map each element of a structure to an action, evaluate these actions from left to right, and collect the results.

This version of traverse works with the lifted K types which are sometimes difficult to work with when nested. If you need to get concrete types out of your traversal operation then use traverse2 - it needs more generic parameters but it retains the concrete types.

Parameters

type T

Traversable trait

type F

Applicative functor trait

type A

Bound value (input)

type B

Bound value (output)

param f
param ta

Traversable structure

returns

method K<F, K<T, A>> sequence <T, F, A> ( K<T, K<F, A>> ta) Source #

where T : Traversable<T>
where F : Applicative<F>

Evaluate each action in the structure from left to right, and collect the results.

Parameters

type T

Traversable trait

type F

Applicative functor trait

type A

Bound value (input)

param ta

Traversable structure

returns

method K<M, K<T, B>> traverseM <T, M, A, B> ( Func<A, K<M, B>> f, K<T, A> ta) Source #

where T : Traversable<T>
where M : Monad<M>

Map each element of a structure to a monadic action, evaluate these actions from left to right, and collect the results.

Parameters

type T

Traversable trait

type M

Monad trait

type A

Bound value (input)

type B

Bound value (output)

param f
param ta

Traversable structure

returns

method K<M, K<T, A>> sequenceM <T, M, A> ( K<T, K<M, A>> ta) Source #

where T : Traversable<T>
where M : Monad<M>

Evaluate each monadic action in the structure from left to right, and collect the results.

Parameters

type T

Traversable trait

type M

Monad trait

type A

Bound value (input)

param ta

Traversable structure

returns

interface Traversable <T> Source #

where T : Traversable<T>, Functor<T>, Foldable<T>

Functors representing data structures that can be transformed to structures of the same shape by performing an Applicative (or, therefore, Monad) action on each element from left to right.

A more detailed description of what same shape means, the various methods, how traversals are constructed, and example advanced use-cases can be found in the Overview section of Data.Traversable.

Parameters

type T

Methods

method K<F, K<T, B>> Traverse <F, A, B> ( Func<A, K<F, B>> f, K<T, A> ta) Source #

where F : Applicative<F>

method K<F, K<T, A>> Sequence <F, A> ( K<T, K<F, A>> ta) Source #

where F : Applicative<F>

method K<M, K<T, B>> TraverseM <M, A, B> ( Func<A, K<M, B>> f, K<T, A> ta) Source #

where M : Monad<M>

method K<F, K<T, A>> SequenceM <F, A> ( K<T, K<F, A>> ta) Source #

where F : Monad<F>

method K<F, K<T, B>> TraverseDefault <F, A, B> ( Func<A, K<F, B>> f, K<T, A> ta) Source #

where F : Applicative<F>