Either

public enum Either<Left, Right>

Simple implementation of either monad

  • left case

    Declaration

    Swift

    case left(Left)
  • right case

    Declaration

    Swift

    case right(Right)
  • returns left value if there is one

    Declaration

    Swift

    public var left: Left? { get }
  • returns right value if there is one

    Declaration

    Swift

    public var right: Right? { get }
  • Transforms left value of Either. Does nothing if the value contains right

    Throws

    rethrows error thrown from transform

    Declaration

    Swift

    public func mapLeft<T>(_ transform: (Left) throws -> T) rethrows -> Either<T, Right>

    Parameters

    transform

    closure that transforms Left to T

    Return Value

    transformed Either

  • Transforms right value of Either. Does nothing if the value contains left

    Throws

    rethrows error thrown from transform

    Declaration

    Swift

    public func mapRight<T>(_ transform: (Right) throws -> T) rethrows -> Either<Left, T>

    Parameters

    transform

    closure that transforms Right to T

    Return Value

    transformed Either

  • Transforms the either to a either of unrelated type Correctness of such transformation is left on our behalf

    Declaration

    Swift

    public func staticCast<L, R>() -> Either<L, R>
  • A textual representation of this instance.

    Declaration

    Swift

    public var description: String { get }
  • A textual representation of this instance, suitable for debugging.

    Declaration

    Swift

    public var debugDescription: String { get }
  • implementation of an equals operatior

    Declaration

    Swift

    public static func == (lhs: Either, rhs: Either) -> Bool
  • implementation of an not equals operatior

    Declaration

    Swift

    public static func != (lhs: Either, rhs: Either) -> Bool