LanguageExt.Core

LanguageExt.Core Monads Alternative Value Monads

Alternative Value Monads are monadic types that can have an alternative value! What does this mean?

If first we think about a tuple:

(int, string)

This type can represent an int AND a string. Now consider the Either<L, R> monad, this means the value can beLeft OR Right (L or R).

So, this:

Either<int, string>

Means either int OR string. It is the natural dual of tuple.

In the case of Either the Right value is considered the bound value of the monad, and the Left value is considered the alternative value. All of the other alternative value monads can be seen as derivatives or specialisations of Either.

Type Alternative Value Type Bound Value Type
Either<L, R> L R
Option<A> None A
Fin<A> Error A
Validation<Fail, Succ> Seq<Fail> Succ
Nullable<A> null A

The alternative value is usually used to carry errors, but that doesn't have to be the case. It is important to remember that the alternative-value can carry anything you want.

Contents

Sub modules

Either
EitherT
Fin
Nullable
Option
OptionT
TryT
Validation
ValidationT