Type alias Either<L, R>

Either<L, R>: Left<L> | Right<R>

Represents a value that can be either of type L (left) or R (right).

Type Parameters

  • L

    The type of the left value.

  • R

    The type of the right value.

Example

const either1: Either<string, number> = left("Error message");
const either2: Either<string, number> = right(42);

const result1 = fold(
either1,
(errorMessage) => `Error: ${errorMessage}`,
(value) => `Success: ${value}`
); // "Error: Error message"

const result2 = fold(
either2,
(errorMessage) => `Error: ${errorMessage}`,
(value) => `Success: ${value}`
); // "Success: 42"

Since

version 1.3.0

Author

Manuel Santos ney.br.santos@gmail.com

Generated using TypeDoc