A guide to Effect-TS following the Red Book pedagogy: build from scratch, discover the algebra, name the pattern last.
- Introduction — What this book is, who it's for, and how to read it
-
Chapter 1 — Why Effect? The real cost of
try/catch,Promise, and manual error handling. Programs as values. -
Chapter 2 — Option, Either, and the Algebra of Errors Building
OptionandEitherfrom scratch.map,flatMap,zip,pipe. The pattern emerges. -
Chapter 3 — The Effect Type: Core Operations From
EithertoEffect.Effect.gen, typed error composition, and theEffect<A, E, R>triple.
-
Chapter 4a — Error Handling: Tagged Errors and Recovery Tagged error types,
catchTag,catchAll,mapError,orElse. Surgical error recovery. -
Chapter 4b — Deep Error Model: Cause, Schema, and Accumulation The
Causetype, defects vs. expected errors,Schemavalidation, fail-fast vs. error accumulation.
-
Chapter 5 — Resource Management and Scoping
acquireRelease,Scope, composable resource lifetimes. Guaranteed cleanup in a world where anything can fail. -
Chapter 6 — Dependency Injection with Layers
Context.Tag,Layer, compile-time dependency graphs. Testable, composable service wiring.
- Chapter 7 — Concurrency and Fibers
Fibers, structured concurrency,
Ref,Queue,Deferred,race, bounded parallelism.
-
Chapter 8a — Streams: Lazy, Effectful Sequences
Streamconstructors,map,flatMap,filter,Sink. The same algebra on sequences. -
Chapter 8b — Stream Patterns for Distributed Systems Resource-safe streams,
groupedWithin, merging, a realistic distributed event processor.
- Chapter 9 — Scheduling, Retries, and Repetition
Scheduleas composable values. Exponential backoff, jitter, windowing, conditional retry.
- Chapter 10 — The Grand Unification Functor, Applicative, Monad — named at last. The complete pattern map. Capstone exercise.
Every chapter discovers the same operations on a new type:
wrap |
transform |
chain |
combine |
|
|---|---|---|---|---|
| Option | some(a) |
map |
flatMap |
zip |
| Either | right(a) |
map |
flatMap |
zip |
| Effect | succeed(a) |
map |
flatMap |
zip |
| Stream | make(a) |
map |
flatMap |
zip |
| Schedule | succeed(a) |
map |
flatMap |
— |
| Layer | succeed(t,v) |
— | — | merge |
- Comfortable with TypeScript
- No functional programming background required
- No prior Effect experience needed
Inspired by Functional Programming in Scala (the Red Book) by Paul Chiusano and Rune Bjarnason.
This work is licensed under CC BY-SA 4.0.