Show / Hide Table of Contents

Interface IOptionMonad<T, TSelf>

Represents the common interface for all option monads.

Inherited Members
IOptionMonad<T>.Or(T)
IOptionMonad<T>.OrInvoke(Func<T>)
IOptionMonad<T>.TryGet(out T)
IOptionMonad<T>.HasValue
IOptionMonad<T>.ValueOrDefault
ISupplier<object>.Invoke()
IFunctional.DynamicInvoke(scoped ref readonly Variant, int, scoped Variant)
IFunctional.GetArgument<T>(ref readonly Variant, int)
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public interface IOptionMonad<T, TSelf> : IOptionMonad<T>, ISupplier<object?>, IFunctional where TSelf : struct, IOptionMonad<T, TSelf>
Type Parameters
Name Description
T

The type of the value in the container.

TSelf

The implementing type.

Operators

View Source

operator |(in TSelf, T?)

Returns the value if present; otherwise return default value.

Declaration
public static T? operator |(in TSelf container, T? defaultValue)
Parameters
Type Name Description
TSelf container

The container to check.

T defaultValue

The value to be returned if there is no value present.

Returns
Type Description
T

The value, if present, otherwise defaultValue.

View Source

operator |(in TSelf, in TSelf)

Returns non-empty container.

Declaration
public static TSelf operator |(in TSelf x, in TSelf y)
Parameters
Type Name Description
TSelf x

The first container.

TSelf y

The second container.

Returns
Type Description
TSelf

The first non-empty container.

View Source

explicit operator T(in TSelf)

Attempts to extract the value from the container.

Declaration
public static abstract explicit operator T(in TSelf container)
Parameters
Type Name Description
TSelf container

The container.

Returns
Type Description
T

The extracted value.

View Source

operator false(in TSelf)

Checks whether the container has no value.

Declaration
public static bool operator false(in TSelf container)
Parameters
Type Name Description
TSelf container

The container to check.

Returns
Type Description
bool

true if this container has no value; otherwise, false.

View Source

implicit operator TSelf(T)

Places the value to the container.

Declaration
public static abstract implicit operator TSelf(T value)
Parameters
Type Name Description
T value

The value to be placed into the container.

Returns
Type Description
TSelf

The constructed monad.

View Source

operator !(in TSelf)

Checks whether the container has no value.

Declaration
public static bool operator !(in TSelf container)
Parameters
Type Name Description
TSelf container

The container to check.

Returns
Type Description
bool

true if this container has no value; otherwise, false.

View Source

operator true(in TSelf)

Checks whether the container has value.

Declaration
public static bool operator true(in TSelf container)
Parameters
Type Name Description
TSelf container

The container to check.

Returns
Type Description
bool

true if this container has value; otherwise, false.

  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾