LanguageExt.Core

LanguageExt.Core Monads Alternative Monads Option Extensions

Contents

class OptionExtensions Source #

Extension methods for Option

Methods

method Option<A> As <A> (this K<Option, A> ma) Source #

method Validation<F, A> ToValidation <F, A> (Option<A> ma, F defaultFailureValue) Source #

where F : Monoid<F>

method Option<A> Flatten <A> (this Option<Option<A>> ma) Source #

Monadic join

method IEnumerable<A> Somes <A> (this IEnumerable<Option<A>> self) Source #

Extracts from a list of Option all the Some elements. All the Some elements are extracted in order.

method Seq<A> Somes <A> (this Seq<Option<A>> self) Source #

Extracts from a list of Option all the Some elements. All the Some elements are extracted in order.

method Option<A> Add <ARITH, A> (this Option<A> x, Option<A> y) Source #

where ARITH : Arithmetic<A>

Add the bound values of x and y, uses an Add trait to provide the add operation for type A. For example x.Add〈TInteger, int〉(y)

Parameters

type ADD

Add of A

type A

Bound value type

param x

Left hand side of the operation

param y

Right hand side of the operation

returns

An option with y added to x

method Option<A> Subtract <ARITH, A> (this Option<A> x, Option<A> y) Source #

where ARITH : Arithmetic<A>

Find the difference between the two bound values of x and y, uses a Subtract trait to provide the subtract operation for type A. For example x.Subtract〈TInteger, int〉(y)

Parameters

type DIFF

Subtract of A

type A

Bound value type

param x

Left hand side of the operation

param y

Right hand side of the operation

returns

An option with the difference between x and y

method Option<A> Product <ARITH, A> (this Option<A> x, Option<A> y) Source #

where ARITH : Arithmetic<A>

Find the product between the two bound values of x and y, uses a Product trait to provide the product operation for type A. For example x.Product〈TInteger, int〉(y)

Parameters

type PROD

Product of A

type A

Bound value type

param x

Left hand side of the operation

param y

Right hand side of the operation

returns

An option with the product of x and y

method Option<A> Divide <NUM, A> (this Option<A> x, Option<A> y) Source #

where NUM : Num<A>

Divide the two bound values of x and y, uses a Divide trait to provide the divide operation for type A. For example x.Divide〈TDouble, double〉(y)

Parameters

type DIV

Divide of A

type A

Bound value type

param x

Left hand side of the operation

param y

Right hand side of the operation

returns

An option x / y

method A? ToNullable <A> (this Option<A> ma) Source #

where A : struct

Convert the Option type to a Nullable of A

Parameters

type A

Type of the bound value

param ma

Option to convert

returns

Nullable of A

method R Match <R> (this Option<bool> ma, Func<R> True, Func<R> False, Func<R> None) Source #

Match for an optional boolean

Parameters

type R
param ma

Optional boolean

param True

Match for Some(true)

param False

Match for Some(false)

param None

Match for None

returns

method IEnumerable<R> Match <T, R> (this IEnumerable<Option<T>> list, Func<T, IEnumerable<R>> Some, Func<IEnumerable<R>> None) Source #

Match over a list of options

Parameters

type T

Type of the bound values

type R

Result type

param list

List of options to match against

param Some

Operation to perform when an Option is in the Some state

param None

Operation to perform when an Option is in the None state

returns

An enumerable of results of the match operations

method IEnumerable<R> Match <T, R> (this IEnumerable<Option<T>> list, Func<T, IEnumerable<R>> Some, IEnumerable<R> None) Source #

Match over a list of options

Parameters

type T

Type of the bound values

type R

Result type

param list

List of options to match against

param Some

Operation to perform when an Option is in the Some state

param None

Default if the list is empty

returns

An enumerable of results of the match operations

class OptionExtensions Source #

Methods

method Option<B> Map <A, B> (this Func<A, B> f, K<Option, A> ma) Source #

Functor map operation

Unwraps the value within the functor, passes it to the map function f provided, and then takes the mapped value and wraps it back up into a new functor.

Parameters

param ma

Functor to map

param f

Mapping function

returns

Mapped functor

method Option<B> Map <A, B> (this Func<A, B> f, Option<A> ma) Source #

Functor map operation

Unwraps the value within the functor, passes it to the map function f provided, and then takes the mapped value and wraps it back up into a new functor.

Parameters

param ma

Functor to map

param f

Mapping function

returns

Mapped functor

method Option<B> Action <A, B> (this Option<A> ma, K<Option, B> mb) Source #

Applicative action: runs the first applicative, ignores the result, and returns the second applicative

method Option<B> Action <A, B> (this K<Option, A> ma, K<Option, B> mb) Source #

Applicative action: runs the first applicative, ignores the result, and returns the second applicative

method Option<B> Apply <A, B> (this Option<Func<A, B>> mf, K<Option, A> ma) Source #

Applicative functor apply operation

Unwraps the value within the ma applicative-functor, passes it to the unwrapped function(s) within mf, and then takes the resulting value and wraps it back up into a new applicative-functor.

Parameters

param ma

Value(s) applicative functor

param mf

Mapping function(s)

returns

Mapped applicative functor

method Option<B> Apply <A, B> (this K<Option, Func<A, B>> mf, K<Option, A> ma) Source #

Applicative functor apply operation

Unwraps the value within the ma applicative-functor, passes it to the unwrapped function(s) within mf, and then takes the resulting value and wraps it back up into a new applicative-functor.

Parameters

param ma

Value(s) applicative functor

param mf

Mapping function(s)

returns

Mapped applicative functor