LanguageExt.Core

LanguageExt.Core Monads Alternative Monads OptionT

Contents

record OptionT <M, A> (K<M, Option<A>> runOption) Source #

where M : Monad<M>

OptionT monad transformer, which allows for an optional result.

Parameters

type M

Given monad trait

type A

Bound value type

param runOption

Transducer that represents the transformer operation

Fields

field OptionT<M, A> None = Lift(Option<A>.None) Source #

Lift a pure value into the monad-transformer

Parameters

param value

Value to lift

returns

OptionT

Methods

method OptionT<M, A> Some (A value) Source #

Lift a pure value into the monad-transformer

Parameters

param value

Value to lift

returns

OptionT

method OptionT<M, A> Lift (Pure<A> monad) Source #

Lifts a given monad into the transformer

Parameters

param monad

Monad to lift

returns

OptionT

method OptionT<M, A> Lift (Option<A> monad) Source #

Lifts a given monad into the transformer

Parameters

param monad

Monad to lift

returns

OptionT

method OptionT<M, A> Lift (Fail<Unit> monad) Source #

Lifts a given monad into the transformer

Parameters

param monad

Monad to lift

returns

OptionT

method OptionT<M, A> Lift (K<M, A> monad) Source #

Lifts a given monad into the transformer

Parameters

param monad

Monad to lift

returns

OptionT

method OptionT<M, A> Lift (K<M, Option<A>> monad) Source #

Lifts a given monad into the transformer

Parameters

param monad

Monad to lift

returns

OptionT

method OptionT<M, A> LiftIO (IO<A> monad) Source #

Lifts a given monad into the transformer

Parameters

param monad

Monad to lift

returns

OptionT

method OptionT<M, A> LiftIO (IO<Option<A>> monad) Source #

Lifts a given monad into the transformer

Parameters

param monad

Monad to lift

returns

OptionT

method K<M, B> Match <B> (Func<A, B> Some, Func<B> None) Source #

Match the two states of the Option and return a B, which can be null.

Parameters

type B

Return type

param Some

Some match operation. May return null.

param None

None match operation. May return null.

returns

B, or null

method K<M, Unit> Match (Action<A> Some, Action None) Source #

Match the two states of the Option

Parameters

param Some

Some match operation

param None

None match operation

method K<M, Unit> IfSome (Action<A> f) Source #

Invokes the action if Option is in the Some state, otherwise nothing happens.

Parameters

param f

Action to invoke if Option is in the Some state

method K<M, Unit> IfSome (Func<A, Unit> f) Source #

Invokes the f function if Option is in the Some state, otherwise nothing happens.

Parameters

param f

Function to invoke if Option is in the Some state

method K<M, A> IfNone (Func<A> None) Source #

Returns the result of invoking the None() operation if the optional is in a None state, otherwise the bound Some(x) value is returned.

Will not accept a null return value from the None operation

Parameters

param None

Operation to invoke if the structure is in a None state

returns

Result of invoking the None() operation if the optional is in a None state, otherwise the bound Some(x) value is returned.

method K<M, Unit> IfNone (Action None) Source #

Invokes the action if Option is in the None state, otherwise nothing happens.

Parameters

param f

Action to invoke if Option is in the None state

method K<M, A> IfNone (A noneValue) Source #

Returns the noneValue if the optional is in a None state, otherwise the bound Some(x) value is returned.

Will not accept a null noneValue

Parameters

param noneValue

Value to return if in a None state

returns

noneValue if the optional is in a None state, otherwise the bound Some(x) value is returned

method K<M, Option<A>> Run () Source #

Runs the OptionT exposing the outer monad with an inner wrapped Option

method OptionT<M1, B> MapT <M1, B> (Func<K<M, Option<A>>, K<M1, Option<B>>> f) Source #

where M1 : Monad<M1>

Maps the bound monad

Parameters

type M1

Target monad type

type B

Target bound value type

param f

Mapping function

returns

Mapped monad

method OptionT<M, B> MapM <B> (Func<K<M, A>, K<M, B>> f) Source #

Maps the given monad

Parameters

param f

Mapping function

method OptionT<M, B> Map <B> (Func<A, B> f) Source #

Maps the bound value

Parameters

type B

Target bound value type

param f

Mapping function

returns

OptionT

method OptionT<M, B> Select <B> (Func<A, B> f) Source #

Maps the bound value

Parameters

type B

Target bound value type

param f

Mapping transducer

returns

OptionT

method OptionT<M, B> Bind <B> (Func<A, K<OptionT<M>, B>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

OptionT

method OptionT<M, B> Bind <B> (Func<A, OptionT<M, B>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

OptionT

method OptionT<M, B> BiBind <B> (Func<A, OptionT<M, B>> Some, Func<OptionT<M, B>> None) Source #

Monad bi-bind operation

Parameters

type B

Target bound value type

param Some

Some state mapping function

param None

None state mapping function

returns

OptionT

method OptionT<M, A> BindNone (Func<OptionT<M, A>> None) Source #

Monad bi-bind operation

Parameters

type B

Target bound value type

param None

None state mapping function

returns

OptionT

method OptionT<M, B> Bind <B> (Func<A, IO<B>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

OptionT

method OptionT<M, B> Bind <B> (Func<A, Pure<B>> f) Source #

Monad bind operation

Parameters

type B

Target bound value type

param f

Mapping function

returns

OptionT

method OptionT<M, C> SelectMany <B, C> (Func<A, K<OptionT<M>, B>> bind, Func<A, B, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

OptionT

method OptionT<M, C> SelectMany <B, C> (Func<A, OptionT<M, B>> bind, Func<A, B, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

OptionT

method OptionT<M, C> SelectMany <B, C> (Func<A, K<M, B>> bind, Func<A, B, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

OptionT

method OptionT<M, C> SelectMany <B, C> (Func<A, Option<B>> bind, Func<A, B, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

OptionT

method OptionT<M, C> SelectMany <B, C> (Func<A, Pure<B>> bind, Func<A, B, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

OptionT

method OptionT<M, C> SelectMany <B, C> (Func<A, IO<B>> bind, Func<A, B, C> project) Source #

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

OptionT

method EitherT<L, M, A> ToEither <L> (L left) Source #

method EitherT<L, M, A> ToEither <L> (Func<L> left) Source #

method EitherT<L, M, A> ToEither <L> () Source #

where L : Monoid<L>

method StreamT<M, A> ToStream () Source #

Operators

operator >> (OptionT<M, A> lhs, OptionT<M, A> rhs) Source #

Sequentially compose two actions, discarding any value produced by the first, like sequencing operators (such as the semicolon) in C#.

Parameters

param lhs

First action to run

param rhs

Second action to run

returns

Result of the second action

operator >> (OptionT<M, A> lhs, K<OptionT<M>, A> rhs) Source #

Sequentially compose two actions, discarding any value produced by the first, like sequencing operators (such as the semicolon) in C#.

Parameters

param lhs

First action to run

param rhs

Second action to run

returns

Result of the second action

operator >> (OptionT<M, A> lhs, OptionT<M, Unit> rhs) Source #

Sequentially compose two actions. The second action is a unit returning action, so the result of the first action is propagated.

Parameters

param lhs

First action to run

param rhs

Second action to run

returns

Result of the first action

operator >> (OptionT<M, A> lhs, K<OptionT<M>, Unit> rhs) Source #

Sequentially compose two actions. The second action is a unit returning action, so the result of the first action is propagated.

Parameters

param lhs

First action to run

param rhs

Second action to run

returns

Result of the first action

operator | (OptionT<M, A> lhs, OptionT<M, A> rhs) Source #

operator | (K<OptionT<M>, A> lhs, OptionT<M, A> rhs) Source #

operator | (OptionT<M, A> lhs, K<OptionT<M>, A> rhs) Source #

operator | (OptionT<M, A> ma, Pure<A> mb) Source #

operator | (OptionT<M, A> ma, Fail<Unit> _) Source #

operator | (OptionT<M, A> ma, CatchM<Unit, OptionT<M>, A> mb) Source #

class OptionTExtensions Source #

OptionT monad-transformer extensions

Methods

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

where M : Monad<M>

method K<M, Option<A>> Run <M, A> (this K<OptionT<M>, A> ma) Source #

where M : Monad<M>

method OptionT<IO, A> Flatten <A> (this Task<OptionT<IO, A>> tma) Source #

Get the outer task and wrap it up in a new IO within the OptionT IO

method OptionT<IO, A> ToIO <A> (this Task<Option<A>> ma) Source #

Lift the task

method OptionT<M, A> Flatten <M, A> (this OptionT<M, OptionT<M, A>> mma) Source #

where M : Monad<M>

Monadic join

method OptionT<M, C> SelectMany <M, A, B, C> ( this K<M, A> ma, Func<A, K<OptionT<M>, B>> bind, Func<A, B, C> project) Source #

where M : Monad<M>

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

OptionT

method OptionT<M, C> SelectMany <M, A, B, C> ( this K<M, A> ma, Func<A, OptionT<M, B>> bind, Func<A, B, C> project) Source #

where M : Monad<M>

Monad bind operation

Parameters

type B

Intermediate bound value type

type C

Target bound value type

param bind

Monadic bind function

param project

Projection function

returns

OptionT

class OptionTExtensions Source #

Methods

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

where M : Monad<M>

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 OptionT<M, B> Map <M, A, B> (this Func<A, B> f, OptionT<M, A> ma) Source #

where M : Monad<M>

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 OptionT<M, B> Action <M, A, B> (this OptionT<M, A> ma, K<OptionT<M>, B> mb) Source #

where M : Monad<M>

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

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

where M : Monad<M>

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

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

where M : Monad<M>

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 OptionT<M, B> Apply <M, A, B> (this K<OptionT<M>, Func<A, B>> mf, K<OptionT<M>, A> ma) Source #

where M : Monad<M>

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

class OptionT <M> Source #

Methods

method OptionT<M, A> Some <A> (A value) Source #

method OptionT<M, A> None <A> () Source #

method OptionT<M, A> lift <A> (Option<A> ma) Source #

method OptionT<M, A> lift <A> (Pure<A> ma) Source #

method OptionT<M, A> lift <A> (Fail<Unit> ma) Source #

method OptionT<M, A> liftIO <A> (IO<A> ma) Source #

class OptionT Source #

Methods

method OptionT<M, B> bind <M, A, B> (OptionT<M, A> ma, Func<A, OptionT<M, B>> f) Source #

where M : Monad<M>

method OptionT<M, B> map <M, A, B> (Func<A, B> f, OptionT<M, A> ma) Source #

where M : Monad<M>

method OptionT<M, A> Some <M, A> (A value) Source #

where M : Monad<M>

method OptionT<M, A> None <M, A> () Source #

where M : Monad<M>

method OptionT<M, A> lift <M, A> (Option<A> ma) Source #

where M : Monad<M>

method OptionT<M, A> lift <M, A> (K<M, A> ma) Source #

where M : Monad<M>

method OptionT<M, A> lift <M, A> (Pure<A> ma) Source #

where M : Monad<M>

method OptionT<M, A> lift <M, A> (Fail<Unit> ma) Source #

where M : Monad<M>

method OptionT<M, A> liftIO <M, A> (IO<A> ma) Source #

where M : Monad<M>

method K<M, B> match <M, A, B> (OptionT<M, A> ma, Func<A, B> Some, Func<B> None) Source #

where M : Monad<M>

class OptionT <M> Source #

where M : Monad<M>

Trait implementation for OptionT

Parameters

type M

Given monad trait

class Prelude Source #

Methods

method OptionT<M, B> map <M, A, B> (Func<A, B> f, K<OptionT<M>, A> ma) Source #

where M : Monad<M>

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 OptionT<M, B> action <M, A, B> (K<OptionT<M>, A> ma, OptionT<M, B> mb) Source #

where M : Monad<M>

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

method OptionT<M, B> apply <M, A, B> (K<OptionT<M>, Func<A, B>> mf, K<OptionT<M>, A> ma) Source #

where M : Monad<M>

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