LanguageExt.Core

LanguageExt.Core Common Result

Contents

struct OptionalResult <A> Source #

Represents the result of an operation:

Some(A) | None | Exception

Result<A> (and OptionalResult<A>) is purely there to represent a concrete result value of a invoked lazy operation (like Try<A>). You're not really meant to consume it directly.

For example:

var ma = Try(...);
var ra = ma(); // This will produce a `Result<A>` because that's what the `Try` delegate returns

But you should be matching on the result, or using any of the other convenient extension methods to get a concrete value:

var ma = Try(...);
var ra1 = ma.IfFail(0);
var ra1 = ma.Match(Succ: x => x + 10, Fail: 0);
// ... etc ...

Parameters

type A

Bound value type

Properties

property bool IsBottom Source #

True if the result is in a bottom state

property bool IsFaulted Source #

True if the result is faulted

property bool IsNone Source #

True if the result is valid, but None

property bool IsSome Source #

True if the result is valid and Some

property bool IsFaultedOrNone Source #

True if the result is faulted

Constructors

constructor OptionalResult (Option<A> value) Source #

Constructor of a concrete value

Parameters

param value

constructor OptionalResult (Exception e) Source #

Constructor of an error value

Parameters

param e

Methods

method OptionalResult<A> Some (A value) Source #

method OptionalResult<A> Optional (A value) Source #

method string ToString () Source #

Convert the value to a showable string

method bool Equals (OptionalResult<A> other) Source #

Equality check

method bool Equals (object obj) Source #

Equality check

method int GetHashCode () Source #

Get hash code for bound value

method A IfFailOrNone (A defaultValue) Source #

method Option<A> IfFail (Func<Exception, A> f) Source #

method Unit IfFailOrNone (Action f) Source #

method Unit IfFail (Action<Exception> f) Source #

method Unit IfSucc (Action<A> f) Source #

method R Match <R> (Func<A, R> Some, Func<R> None, Func<Exception, R> Fail) Source #

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

method Task<OptionalResult<B>> MapAsync <B> (Func<A, Task<B>> f) Source #

method int CompareTo (OptionalResult<A> other) Source #

Operators

operator == (OptionalResult<A> a, OptionalResult<A> b) Source #

operator != (OptionalResult<A> a, OptionalResult<A> b) Source #

operator < (OptionalResult<A> a, OptionalResult<A> b) Source #

operator <= (OptionalResult<A> a, OptionalResult<A> b) Source #

operator > (OptionalResult<A> a, OptionalResult<A> b) Source #

operator >= (OptionalResult<A> a, OptionalResult<A> b) Source #

struct Result <A> Source #

Represents the result of an operation:

A | Exception

Result<A> (and OptionalResult<A>) is purely there to represent a concrete result value of a invoked lazy operation (like Try<A>). You're not really meant to consume it directly.

For example:

var ma = Try(...);
var ra = ma(); // This will produce a `Result<A>` because that's what the `Try` delegate returns

But you should be matching on the result, or using any of the other convenient extension methods to get a concrete value:

var ma = Try(...);
var ra1 = ma.IfFail(0);
var ra1 = ma.Match(Succ: x => x + 10, Fail: 0);
// ... etc ...

Parameters

type A

Bound value type

Fields

Properties

property bool IsFaulted Source #

True if the result is faulted

property bool IsBottom Source #

True if the struct is in an invalid state

property bool IsSuccess Source #

True if the struct is in an success

Constructors

constructor Result (A value) Source #

Constructor of a concrete value

Parameters

param value

constructor Result (Exception e) Source #

Constructor of an error value

Parameters

param e

Methods

method string ToString () Source #

Convert the value to a showable string

method bool Equals (Result<A> other) Source #

Equality check

method bool Equals (object obj) Source #

Equality check

method int GetHashCode () Source #

Get hash code for bound value

method A IfFail (A defaultValue) Source #

method A IfFail (Func<Exception, A> f) Source #

method Unit IfFail (Action<Exception> f) Source #

method Unit IfSucc (Action<A> f) Source #

method R Match <R> (Func<A, R> Succ, Func<Exception, R> Fail) Source #

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

method Task<Result<B>> MapAsync <B> (Func<A, Task<B>> f) Source #

method int CompareTo (Result<A> other) Source #

Operators

operator == (Result<A> a, Result<A> b) Source #

operator != (Result<A> a, Result<A> b) Source #

operator < (Result<A> a, Result<A> b) Source #

operator <= (Result<A> a, Result<A> b) Source #

operator > (Result<A> a, Result<A> b) Source #

operator >= (Result<A> a, Result<A> b) Source #