LanguageExt.Core

LanguageExt.Core Traits Optional

Contents

interface Optional <OA, A> Source #

Properties

property OA None Source #

Methods

method bool IsSome (OA opt) Source #

Is the option in a Some state

method bool IsNone (OA opt) Source #

Is the option in a None state

method B Match <B> (OA opt, Func<A, B> Some, Func<B> None) Source #

Match the two states of the Option and return a non-null B.

method B Match <B> (OA opt, Func<A, B> Some, B None) Source #

Match the two states of the Option and return a non-null B.

method Unit Match (OA opt, Action<A> Some, Action None) Source #

Match the two states of the Option A

Parameters

param Some

Some match operation

param None

None match operation

method OA Some (A value) Source #

method OA MkOptional (A value) Source #

class Optional Source #

Methods

method Unit ifSome <OPT, OA, A> (OA opt, Action<A> f) Source #

where OPT : Optional<OA, A>

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

method Unit ifSome <OPT, OA, A> (OA opt, Func<A, Unit> f) Source #

where OPT : Optional<OA, A>

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

method A ifNone <OPT, OA, A> (OA opt, Func<A> None) Source #

where OPT : Optional<OA, A>

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

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

method A ifNone <OPT, OA, A> (OA opt, A noneValue) Source #

where OPT : Optional<OA, A>

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 R matchUntyped <OPT, OA, A, R> (OA ma, Func<object?, R> Some, Func<R> None) Source #

where OPT : Optional<OA, A>

Match operation with an untyped value for Some. This can be useful for serialisation and dealing with the IOptional interface

Parameters

type R

The return type

param Some

Operation to perform if the option is in a Some state

param None

Operation to perform if the option is in a None state

returns

The result of the match operation

method Arr<A> toArray <OPT, OA, A> (OA ma) Source #

where OPT : Optional<OA, A>

Convert the Option to an enumerable of zero or one items

Parameters

param ma

Option

returns

An enumerable of zero or one items

method Lst<A> toList <OPT, OA, A> (OA ma) Source #

where OPT : Optional<OA, A>

Convert the Option to an immutable list of zero or one items

Parameters

param ma

Option

returns

An immutable list of zero or one items

method Seq<A> asEnumerable <OPT, OA, A> (OA ma) Source #

where OPT : Optional<OA, A>

Convert the Option to an enumerable of zero or one items

Parameters

type A

Bound value type

param ma

Option

returns

An enumerable of zero or one items

method Either<L, A> toEither <OPT, OA, L, A> (OA ma, L defaultLeftValue) Source #

where OPT : Optional<OA, A>

Convert the structure to an Either

method Either<L, A> toEither <OPT, OA, L, A> (OA ma, Func<L> Left) Source #

where OPT : Optional<OA, A>

Convert the structure to an Either

method Option<A> toOption <OPT, OA, A> (OA ma) Source #

where OPT : Optional<OA, A>

Convert the structure to a Option