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