t-tasks
    Preparing search index...

    Interface Left<R, L>

    Left (erroneous) value of type L

    Either data type specialization representing an erroneous value

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

    Type Parameters

    • R

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

    • L

      underlying error type

    Index

    Properties

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

    Wrap Either to singleton generator

    Useful in order to avoid ambiguous yield types

    generator of Either 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')

      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')

      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: R) => R2

        transformer to be invoked with underlying value

      Returns Left<never, L>

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

    • Type Parameters

      • R2

      Parameters

      Returns Either<R2, L>

    • Either pattern matching extractor function

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

      Type Parameters

      • R2

        right extractor function's return type

      • R3 = R2

        left extractor function's return type

      Parameters

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

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

        • right: (value: R) => R2

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

      Returns R3

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

    • Type Parameters

      Parameters

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

      Returns R2 | R3

    • 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: L) => R3; right: (value: R) => R2 }
        • left: (error: L) => R3

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

        • right: (value: R) => R2

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

      Returns Right<R3, never>

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

    • Type Parameters

      Parameters

      • this: Either<R, L>
      • op: { left: (error: L) => R3; right: (value: R) => 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: L) => void; right: (value: R) => void }
        • left: (error: L) => void

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

        • right: (value: R) => void

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

      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

        transformer function's return type

      Parameters

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

        transformer to be invoked with underlying error

      Returns Right<R2, never>

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

    • Type Parameters

      • R2

      Parameters

      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: L) => void

        function to be invoked with underlying error

      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: R) => void

        function to be invoked with underlying value

      Returns this

      self