Search Results for

    Show / Hide Table of Contents

    Class Either<TA, TB>

    Represents a value of one of two possible types (a disjoint union). An instance of Either is either a Left or a Right.

    Inheritance
    object
    Either<TA, TB>
    Left<TA, TB>
    Right<TA, TB>
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Akka.Util
    Assembly: Akka.dll
    Syntax
    public abstract class Either<TA, TB>
    Type Parameters
    Name Description
    TA

    The type of the value if this is a Left instance.

    TB

    The type of the value if this is a Right instance.

    Constructors

    | Edit this page View Source

    Either(TA, TB)

    Initializes a new instance of the Either<TA, TB> class.

    Declaration
    protected Either(TA left, TB right)
    Parameters
    Type Name Description
    TA left

    The left value.

    TB right

    The right value.

    Properties

    | Edit this page View Source

    IsLeft

    Gets a value indicating whether this instance represents a Left.

    Declaration
    public abstract bool IsLeft { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    IsRight

    Gets a value indicating whether this instance represents a Right.

    Declaration
    public abstract bool IsRight { get; }
    Property Value
    Type Description
    bool
    | Edit this page View Source

    Left

    Gets the left value.

    Declaration
    protected TA Left { get; }
    Property Value
    Type Description
    TA
    | Edit this page View Source

    Right

    Gets the right value.

    Declaration
    protected TB Right { get; }
    Property Value
    Type Description
    TB
    | Edit this page View Source

    Value

    Gets the contained value, either Left or Right.

    Declaration
    public object Value { get; }
    Property Value
    Type Description
    object

    Methods

    | Edit this page View Source

    Fold<TRes>(Func<TA, TRes>, Func<TB, TRes>)

    Applies one of the provided functions depending on whether this is a Left or Right.

    Declaration
    public TRes Fold<TRes>(Func<TA, TRes> left, Func<TB, TRes> right)
    Parameters
    Type Name Description
    Func<TA, TRes> left

    The function to apply if this is a Left.

    Func<TB, TRes> right

    The function to apply if this is a Right.

    Returns
    Type Description
    TRes

    The result of applying the corresponding function.

    Type Parameters
    Name Description
    TRes

    The type of the result.

    | Edit this page View Source

    MapLeft<TRes>(Func<TA, TRes>)

    Maps the left value contained in this Either instance.

    Declaration
    public Either<TRes, TB> MapLeft<TRes>(Func<TA, TRes> map)
    Parameters
    Type Name Description
    Func<TA, TRes> map

    The function to apply to the left value if this is a Left.

    Returns
    Type Description
    Either<TRes, TB>

    A new Either instance with the transformed left value.

    Type Parameters
    Name Description
    TRes

    The type of the transformed left value.

    | Edit this page View Source

    MapRight<TRes>(Func<TB, TRes>)

    Maps the right value contained in this Either instance.

    Declaration
    public Either<TA, TRes> MapRight<TRes>(Func<TB, TRes> map)
    Parameters
    Type Name Description
    Func<TB, TRes> map

    The function to apply to the right value if this is a Right.

    Returns
    Type Description
    Either<TA, TRes>

    A new Either instance with the transformed right value.

    Type Parameters
    Name Description
    TRes

    The type of the transformed right value.

    | Edit this page View Source

    Map<TRes1, TRes2>(Func<TA, TRes1>, Func<TB, TRes2>)

    Maps the values contained in this Either instance using the provided functions.

    Declaration
    public Either<TRes1, TRes2> Map<TRes1, TRes2>(Func<TA, TRes1> map1, Func<TB, TRes2> map2)
    Parameters
    Type Name Description
    Func<TA, TRes1> map1

    The function to apply to the left value if this is a Left.

    Func<TB, TRes2> map2

    The function to apply to the right value if this is a Right.

    Returns
    Type Description
    Either<TRes1, TRes2>

    A new Either instance with transformed values.

    Type Parameters
    Name Description
    TRes1

    The type of the left result.

    TRes2

    The type of the right result.

    | Edit this page View Source

    ToLeft()

    Converts this instance to a Left instance.

    Declaration
    public Left<TA, TB> ToLeft()
    Returns
    Type Description
    Left<TA, TB>

    A new Left instance containing the left value.

    | Edit this page View Source

    ToRight()

    Converts this instance to a Right instance.

    Declaration
    public Right<TA, TB> ToRight()
    Returns
    Type Description
    Right<TA, TB>

    A new Right instance containing the right value.

    Operators

    | Edit this page View Source

    implicit operator Either<TA, TB>(Left<TA>)

    Performs an implicit conversion from Left<T> to Either<TA, TB>.

    Declaration
    public static implicit operator Either<TA, TB>(Left<TA> left)
    Parameters
    Type Name Description
    Left<TA> left

    The object to convert

    Returns
    Type Description
    Either<TA, TB>

    The result of the conversion.

    | Edit this page View Source

    implicit operator Either<TA, TB>(Right<TB>)

    Performs an implicit conversion from Right<T> to Either<TA, TB>.

    Declaration
    public static implicit operator Either<TA, TB>(Right<TB> right)
    Parameters
    Type Name Description
    Right<TB> right

    The object to convert

    Returns
    Type Description
    Either<TA, TB>

    The result of the conversion.

    Extension Methods

    ObjectExtensions.IsDefaultForType<T>(T)
    ObjectExtensions.AsOption<T>(T)
    Extensions.AsInstanceOf<T>(object)
    In this article
    • githubEdit this page
    • View Source
    Back to top
    Contribute
    • Project Chat
    • Discussion Forum
    • Source Code
    Support
    • Akka.NET Support Plans
    • Akka.NET Observability Tools
    • Akka.NET Training & Consulting
    Maintained By
    • Petabridge - The Akka.NET Company
    • Learn Akka.NET