0Pricing
Kotlin Academy · Lesson

Either<L, R>: Typed Error Handling Without Exceptions

Use Either to represent success and failure without throwing exceptions.

The Problem with Exceptions for Business Logic

Exceptions are designed for unexpected failures (null pointer, IO error). Using them to signal expected business failures (validation failure, "not found") makes control flow invisible, forces try/catch at every call site, and hides errors in function signatures.

What Is Either<L, R>?

Either is a sum type with two cases: Left(value: L) conventionally holds the error, and Right(value: R) conventionally holds the success value. A function returning Either makes the possibility of failure explicit in its signature.

All lessons in this course

  1. Either : Typed Error Handling Without Exceptions
  2. Arrow Raise DSL: Composing Typed Errors
  3. Option and Nullable: When to Use Each
  4. Functional Domain Modeling with Arrow's Core Types
← Back to Kotlin Academy