0Pricing
TypeScript Academy · Lesson

Composing Effects

Chain and combine effects with pipe and generators.

Composing Effects

Effects are values, so you build programs by composing them. The core tools are Effect.pipe, Effect.map, Effect.flatMap, and the generator-based Effect.gen syntax.

pipe: Threading Through Functions

pipe passes an effect through a series of transformations left to right, avoiding deep nesting.

import { Effect, pipe } from "effect";

const program = pipe(
  Effect.succeed(2),
  Effect.map((n) => n + 1),
  Effect.map((n) => n * 10)
);
// Effect<number, never, never> producing 30

All lessons in this course

  1. Why Effect Systems Matter
  2. The Effect Type
  3. Composing Effects
  4. Error Channels and Dependencies
← Back to TypeScript Academy