Effect 4 · 61 lessons

Learn Effect, step by step.

Effect by Effect is a test-driven tutorial for Effect 4. Each lesson is a runnable test file — read the explanation, fill in the stubs, run the suite. You move from Effect<A, E, R> to services, layers, concurrency, streams, and production patterns used in real Effect applications.

// Effect<A, E, R>
//   A  = what you get on success
//   E  = what can go wrong
//   R  = what needs to be provided
//
// Three dimensions. One type. Everything else is discipline.

import { Effect } from "effect"

const divide = (a: number, b: number): Effect.Effect<number, Error, never> =>
  b === 0
    ? Effect.fail(new Error("Cannot divide by zero"))
    : Effect.succeed(a / b)

Effect.runSync(divide(10, 2))
// 5
How this tutorial works
01

Runnable at every step

Every lesson ships with an index.test.ts. Run it locally with pnpm test, or read the generated lesson in your browser. The type system and the test suite keep you honest.

02

Dependency order

Topics appear when you need them. Context and layers come after error handling. Streams come after schedules. You build one mental model and extend it — nothing to unlearn later.

03

Production patterns

Capstones combine retries, dependency injection, schema validation, and observability. The same patterns you will find in Effect's own libraries and documentation.

The curriculum

61 lessons, 10 parts

  1. 01Foundations6 lessons
  2. 05Testing3 lessons
  3. 08Errors at Depth1 lessons
  4. 10Production10 lessons
What you'll build toward

From types to systems

Foundations

Why typed errors beat try/catch, what Effect<A, E, R> describes, and how to create, compose, and run effects with pipe, Effect.gen, and the standard runners.

Services

Context, Layer, and dependency injection — the structure Effect applications use to stay testable.

Testing

Test layers, TestClock, and assertions on Exit — test the program, not the mocks.

Concurrency

Fibers, interruption, Ref, queues, and semaphores — Effect's structured concurrency model in practice.

Production

Config, observability, HTTP clients, CLI parsing, and runtimes — the path from tutorial exercises to deployable code.

Ready?

Clone the repo. Run the tests.

61 lessons, one source tree under steps/. Read here or run locally — same content, same Effect 4 APIs.

Begin the tutorial