> For the complete documentation index, see [llms.txt](https://katxupa.gitbook.io/katxupa/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://katxupa.gitbook.io/katxupa/get-a-taste-of-katxupa/usage/either.md).

# Either

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

```typescript
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"
```
