Foundations

The Effect type

Every API in Effect serves three type parameters. Understand them once, and the rest of the library follows.

Effect <A, E, R> is an immutable description of a computation. When executed, it either succeeds with an A, fails with an E, or requires services R from the environment.

Effect<number, Error, never>
   │      │     │
   │      │     └── R: what needs to be provided (Context)
   │      └──────── E: what can go wrong (Failure)
   └─────────────── A: what you get on success (Value)

Three channels, one type

A Promise<A> only describes success — failure escapes as an untyped exception. Effect models success, failure, and requirements in the type. That is what makes retries, dependency injection, and structured logging composable: the description exists before anything runs.

How the tutorial uses it

Lessons 01–05 make the E channel concrete. Lessons 21–22 make R real through Context and Layer. Everything in between is composition — pipe, Effect.gen, error recovery, and concurrency.

Start at lesson one