LanguageExt.Core

LanguageExt.Core Traits Coproduct

Contents

class CoproductExtensions Source #

Co-product trait (abstract version of Either)

Parameters

type F

Self

Methods

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

where F : Coproduct<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 C Match <F, A, B, C> (this K<F, A, B> fab, C Left, Func<B, C> Right) Source #

where F : Coproduct<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 C Match <F, A, B, C> (this K<F, A, B> fab, Func<A, C> Left, C Right) Source #

where F : Coproduct<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 B IfLeft <F, A, B> (this K<F, A, B> fab, Func<A, B> Left) Source #

where F : Coproduct<F>

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 B IfLeft <F, A, B> (this K<F, A, B> fab, B Left) Source #

where F : Coproduct<F>

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 A IfRight <F, A, B> (this K<F, A, B> fab, Func<B, A> Right) Source #

where F : Coproduct<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

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 A IfRight <F, A, B> (this K<F, A, B> fab, A Right) Source #

where F : Coproduct<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

param fab

Coproduct value

param Right

Default value to use if the state is Right

returns

Either the left value or provided Right value

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

where F : Coproduct<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 (Seq<A> Lefts, Seq<B> Rights) PartitionSequence <F, A, B> (this IEnumerable<K<F, A, B>> fabs) Source #

where F : Coproduct<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 Coproduct Source #

Methods

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

where F : Coproduct<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 : Coproduct<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 (Seq<A> Lefts, Seq<B> Rights) partition <FF, F, A, B> (K<FF, K<F, A, B>> fabs) Source #

where F : Coproduct<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 (Seq<A> Lefts, Seq<B> Rights) partitionSequence <F, A, B> (IEnumerable<K<F, A, B>> fabs) Source #

where F : Coproduct<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 Coproduct <F> Source #

where F : Coproduct<F>

Co-product trait (abstract version of Either)

Parameters

type F

Self

Methods

method 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 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 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 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 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 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 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

method (Seq<A> Lefts, Seq<B> Rights) Partition <FF, A, B> (K<FF, K<F, A, B>> fabs) Source #

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 Seq<A> Lefts <G, A, B> (K<G, K<F, A, B>> fabs) Source #

where G : Foldable<G>

Partition the foldable of coproducts into two left and right sequences, then return the left sequence.

Parameters

type A

Left value type

type B

Right value type

returns

Left sequence

method Seq<B> Rights <G, A, B> (K<G, K<F, A, B>> fabs) Source #

where G : Foldable<G>

Partition the foldable of coproducts into two left and right sequences, then return the right sequence.

Parameters

type A

Left value type

type B

Right value type

returns

Right sequence