Interface Left<R, L>

Left (erroneous) value of type L

Either data type specialization representing an erroneous value

Remplate

R underlying value type (needed for type merging, in fact alwas considered to be never)

interface Left<R, L> {
    generator: EitherGeneratorFunction<[], R, Left<R, L>, R>;
    left: L;
    chain<R2, L2>(this, op): Left<never, L>;
    chain<R2, L2>(this, op): Left<never, L>;
    chain<R2, L2>(this, op): Left<never, L>;
    chain<R2, L2>(this, op): Either<R2, L>;
    chain<R2, L2>(this, op): Left<never, L | L2>;
    chain<R2, L2>(this, op): Either<R2, L | L2>;
    isLeft(): this is Left<R, L>;
    isRight(): this is Right<R, L>;
    map<R2>(this, op): Left<never, L>;
    map<R2>(this, op): Either<R2, L>;
    matchChain<R2, L2, R3, L3>(this, op): Right<R3, never>;
    matchChain<R2, L2, R3, L3>(this, op): Right<R3, never>;
    matchChain<R2, L2, R3, L3>(this, op): Left<never, L3>;
    matchChain<R2, L2, R3, L3>(this, op): Left<never, L3>;
    matchChain<R2, L2, R3, L3>(this, op): Right<R3, never>;
    matchChain<R2, L2, R3, L3>(this, op): Left<never, L3>;
    matchChain<R2, L2, R3, L3>(this, op): Either<R3, L3>;
    matchChain<R2, L2, R3, L3>(this, op): Either<R3, L3>;
    matchChain<R2, L2, R3, L3>(this, op): Either<R3, L3>;
    matchChain<R2, L2, R3, L3>(this, op): Right<R2 | R3, never>;
    matchChain<R2, L2, R3, L3>(this, op): Either<R3, L2>;
    matchChain<R2, L2, R3, L3>(this, op): Either<R2, L3>;
    matchChain<R2, L2, R3, L3>(this, op): Left<never, L2 | L3>;
    matchChain<R2, L2, R3, L3>(this, op): Either<R2 | R3, L2>;
    matchChain<R2, L2, R3, L3>(this, op): Either<R2, L2 | L3>;
    matchChain<R2, L2, R3, L3>(this, op): Either<R2 | R3, L3>;
    matchChain<R2, L2, R3, L3>(this, op): Either<R3, L2 | L3>;
    matchChain<R2, L2, R3, L3>(this, op): Either<R2 | R3, L2 | L3>;
    matchMap<R2, R3>(this, op): Right<R3, never>;
    matchMap<R2, R3>(this, op): Right<R2 | R3, never>;
    matchTap(op): this;
    orChain<R2, L2>(this, op): Right<R2, never>;
    orChain<R2, L2>(this, op): Left<never, L2>;
    orChain<R2, L2>(this, op): Either<R2, L2>;
    orChain<R2, L2>(this, op): Right<R | R2, never>;
    orChain<R2, L2>(this, op): Either<R, L2>;
    orChain<R2, L2>(this, op): Either<R | R2, L2>;
    orMap<R2>(this, op): Right<R2, never>;
    orMap<R2>(this, op): Right<R | R2, never>;
    orTap(op): this;
    tap(op): this;
}

Type Parameters

  • R

  • L

    underlying error type

Properties

generator: EitherGeneratorFunction<[], R, Left<R, L>, R>

Wrap Maybe to singleton generator

Userful in order to avoid ambiguous yied types

Returns

generator of Maybe wrapping this

left: L

Methods

  • Either type guard for 'left'

    Returns this is Left<R, L>

    'true' in case this is 'left error' (and resolves type to be 'left')

    Example

    if (either.isLeft()) {
    console.error(either.left)
    }
  • Either type guard for 'right'

    Returns this is Right<R, L>

    'true' in case this is 'right value' (and resolves type to be 'right')

    Example

    if (either.isRight()) {
    console.log(either.right)
    }
  • Either transformer function

    Applied to 'right value' returns 'right op(value)' Applied to 'left error' returns self without invoking transformer

    Type Parameters

    • R2

      transformer function's return type

    Parameters

    • this: Left<R, L>
    • op: ((value) => R2)

      transformer to be invoked with underlying value

        • (value): R2
        • Parameters

          • value: R

          Returns R2

    Returns Left<never, L>

    'right op(value)' or 'left error'

  • Type Parameters

    • R2

    Parameters

    • this: Either<R, L>
    • op: ((value) => R2)
        • (value): R2
        • Parameters

          • value: R

          Returns R2

    Returns Either<R2, L>

  • Either pattern matching transformer function

    Applied to 'right value' returns 'right op.right(value)' Applied to 'left error' returns 'right op.left(error)'

    Type Parameters

    • R2

      right transformer function's return type

    • R3 = R2

      left transformer function's return type

    Parameters

    • this: Left<R, L>
    • op: {
          left: ((error) => R3);
          right: ((value) => R2);
      }
      • left: ((error) => R3)

        transformer to be invoked with underlying error in case of 'left'

          • (error): R3
          • transformer to be invoked with underlying error in case of 'left'

            Parameters

            • error: L

            Returns R3

      • right: ((value) => R2)

        transformer to be invoked with underlying value in case of 'right'

          • (value): R2
          • transformer to be invoked with underlying value in case of 'right'

            Parameters

            • value: R

            Returns R2

    Returns Right<R3, never>

    'right op.right(value)' or 'right op.left(error)'

  • Type Parameters

    Parameters

    • this: Either<R, L>
    • op: {
          left: ((error) => R3);
          right: ((value) => R2);
      }
      • left: ((error) => R3)
          • (error): R3
          • Parameters

            • error: L

            Returns R3

      • right: ((value) => R2)
          • (value): R2
          • Parameters

            • value: R

            Returns R2

    Returns Right<R2 | R3, never>

  • Either pattern matching peeker function

    Applied to 'right value' returns self invoking op.right(value) in process Applied to 'left error' returns self invoking op.left(error) in process

    Parameters

    • op: {
          left: ((error) => void);
          right: ((value) => void);
      }
      • left: ((error) => void)

        function to be invoked with underlying error in case of 'left'

          • (error): void
          • function to be invoked with underlying error in case of 'left'

            Parameters

            • error: L

            Returns void

      • right: ((value) => void)

        function to be invoked with underlying value in case of 'right'

          • (value): void
          • function to be invoked with underlying value in case of 'right'

            Parameters

            • value: R

            Returns void

    Returns this

    self

  • Either fallback transformer function

    Applied to 'right value' returns self without invoking transformer Applied to 'left error' returns 'right op(error)'

    Type Parameters

    • R2

    Parameters

    • this: Left<R, L>
    • op: ((error) => R2)

      transformer to be invoked with underlying error

        • (error): R2
        • Parameters

          • error: L

          Returns R2

    Returns Right<R2, never>

    'right value' or 'right op(error)'

  • Type Parameters

    • R2

    Parameters

    • this: Either<R, L>
    • op: ((error) => R2)
        • (error): R2
        • Parameters

          • error: L

          Returns R2

    Returns Right<R | R2, never>

  • Either fallback peeker function

    Applied to 'right value' returns self without invoking callback Applied to 'left error' returns self invoking op(error) in process

    Parameters

    • op: ((error) => void)

      function to be invoked with underlying value

        • (error): void
        • Parameters

          • error: L

          Returns void

    Returns this

    self

  • Either peeker function

    Applied to 'right value' returns self invoking op(value) in process Applied to 'left error' returns self without invoking callback

    Parameters

    • op: ((value) => void)

      function to be invoked with underlying value

        • (value): void
        • Parameters

          • value: R

          Returns void

    Returns this

    self

Generated using TypeDoc