LanguageExt.Core

LanguageExt.Core Traits CoproductK

Contents

class CoproductKExtensions Source #

Co-product trait (abstract version of Either)

Parameters

type F

Self

Methods

method K<F, A, C> Match <F, A, B, C> (this K<F, A, B> fab, Func<A, C> Left, Func<B, C> Right) Source #

where F : CoproductK<F>

Pattern-match either the left or right value in the coproduct

Parameters

type F

Coproduct trait type

type A

Left value type

type B

Right value type

type C

Result type

param fab

Coproduct value

param Left

Function to map the left value to a result

param Right

Function to map the right value to a result

returns

Result of mapping either the left or right values with the functions provided

method K<F, A, (Seq<A> Left, Seq<B> Right)> Partition <FF, F, A, B> (this K<FF, K<F, A, B>> fabs) Source #

where F : CoproductK<F>, Bimonad<F>
where FF : Foldable<FF>

Partition the foldable of coproducts into two left and right sequences.

Parameters

type A

Left value type

type B

Right value type

returns

Two left and right sequences

method K<F, A, (Seq<A> Left, Seq<B> Right)> PartitionSequence <F, A, B> (this IEnumerable<K<F, A, B>> fabs) Source #

where F : CoproductK<F>, Bimonad<F>

Partition the foldable of coproducts into two left and right sequences.

Parameters

type A

Left value type

type B

Right value type

returns

Two left and right sequences

class CoproductK Source #

Methods

method K<F, A, B> left <F, A, B> (A value) Source #

where F : CoproductK<F>

Construct a coproduct structure in a 'Left' state

Parameters

type A

Left value type

type B

Right value type

param value

Left value

returns

Constructed coproduct structure

method K<F, A, B> right <F, A, B> (B value) Source #

where F : CoproductK<F>

Construct a coproduct structure in a 'Left' state

Parameters

type A

Left value type

type B

Right value type

param value

Left value

returns

Constructed coproduct structure

method K<F, A, (Seq<A> Left, Seq<B> Right)> partition <FF, F, A, B> (K<FF, K<F, A, B>> fabs) Source #

where F : CoproductK<F>, Bimonad<F>
where FF : Foldable<FF>

Partition the foldable of coproducts into two left and right sequences.

Parameters

type A

Left value type

type B

Right value type

returns

Two left and right sequences

method K<F, A, (Seq<A> Left, Seq<B> Right)> partitionSequence <F, A, B> (IEnumerable<K<F, A, B>> fabs) Source #

where F : CoproductK<F>, Bimonad<F>

Partition the foldable of coproducts into two left and right sequences.

Parameters

type A

Left value type

type B

Right value type

returns

Two left and right sequences

interface CoproductK <F> Source #

where F : CoproductK<F>

Co-product trait (abstract version of Either)

Parameters

type F

Self

Methods

method K<F, A, C> Match <A, B, C> (Func<A, C> Left, Func<B, C> Right, K<F, A, B> fab) Source #

Pattern-match either the left or right value in the coproduct

Parameters

type F

Coproduct trait type

type A

Left value type

type B

Right value type

type C

Result type

param fab

Coproduct value

param Left

Function to map the left value to a result

param Right

Function to map the right value to a result

returns

Result of mapping either the left or right values with the functions provided

method K<F, A, C> Match <A, B, C> (C Left, Func<B, C> Right, K<F, A, B> fab) Source #

Pattern-match either the left or right value in the coproduct

Parameters

type F

Coproduct trait type

type A

Left value type

type B

Right value type

type C

Result type

param fab

Coproduct value

param Left

Function to map the left value to a result

param Right

Function to map the right value to a result

returns

Result of mapping either the left or right values with the functions provided

method K<F, A, C> Match <A, B, C> (Func<A, C> Left, C Right, K<F, A, B> fab) Source #

Pattern-match either the left or right value in the coproduct

Parameters

type F

Coproduct trait type

type A

Left value type

type B

Right value type

type C

Result type

param fab

Coproduct value

param Left

Function to map the left value to a result

param Right

Function to map the right value to a result

returns

Result of mapping either the left or right values with the functions provided

method K<F, A, B> IfLeft <A, B> (Func<A, B> Left, K<F, A, B> fab) Source #

Pattern-match the left value in the coproduct

Parameters

type F

Coproduct trait type

type A

Left value type

type B

Right value type

param fab

Coproduct value

param Left

Function to map the left value to a result

returns

Either the right value or the result of mapping the left with the function provided

method K<F, A, B> IfLeft <A, B> (B Left, K<F, A, B> fab) Source #

Pattern-match the left value in the coproduct

Parameters

type F

Coproduct trait type

type A

Left value type

type B

Right value type

param fab

Coproduct value

param Left

Default value to use if the state is Left

returns

Either the right value or provided Left value

method K<F, A, A> IfRight <A, B> (Func<B, A> Right, K<F, A, B> fab) Source #

Pattern-match either the left or right value in the coproduct

Parameters

type F

Coproduct trait type

type A

Left value type

type B

Right value type

param fab

Coproduct value

param Right

Function to map the right value to a result

returns

Either the left value or the result of mapping the right value with the function provided

method K<F, A, A> IfRight <A, B> (A Right, K<F, A, B> fab) Source #

Pattern-match either the left or right value in the coproduct

Parameters

type F

Coproduct trait type

type A

Left value type

type B

Right value type

param fab

Coproduct value

param Right

Default value to use if the state is Right

returns

Either the left value or provided Right value