Effect
A functional effect-system library for the TypeScript ecosystem. It incorporates error handling into the type system via a three-parameter type Effect<Success, Error, Requirements>, and provides capabilities including typed errors, dependency injection, and lazy evaluation.
Timeline (last 90 days)
The Effect type encodes the success value, error type, and dependency environment all into the type signature.
Effect distinguishes at the type level between two categories of failure: Expected Errors (predictable errors, encoded in the E parameter of Effect<A, E, R>) and Defects.
Commonly used error-handling combinators in Effect include Effect.catchAll, Effect.retry, and Effect.mapError.
Effect's Scope mechanism binds resource lifecycles to Fiber lifecycles, ensuring that acquired resources are released in reverse order when a Fiber completes, errors, or is interrupted.
Effect's structured concurrency design philosophy draws from Kotlin's structured concurrency and ZIO's Scope.
Effect's dependency injection system is composed of three concepts: Context, Tag, and Layer.
Compared to decorator-based DI frameworks such as tsyringe and inversify, Effect's dependency injection operates entirely within the type system, with no runtime metadata dependencies and no need for TypeScript decorator features.
Effect V4 merges many previously scattered packages into the core effect package, and includes 17 unstable modules covering HTTP, RPC, CLI, workflows, clustering, and more.
Effect uses Fibers (lightweight virtual threads) to implement structured concurrency.
Effect is a TypeScript library whose V4 version is in beta.
8 more timeline events
All Facts (18)
The Effect type encodes the success value, error type, and dependency environment all into the type signature.
50%UnverifiedEffect distinguishes at the type level between two categories of failure: Expected Errors (predictable errors, encoded in the E parameter of Effect<A, E, R>) and Defects.
50%UnverifiedCommonly used error-handling combinators in Effect include Effect.catchAll, Effect.retry, and Effect.mapError.
50%UnverifiedEffect's Scope mechanism binds resource lifecycles to Fiber lifecycles, ensuring that acquired resources are released in reverse order when a Fiber completes, errors, or is interrupted.
50%UnverifiedEffect's structured concurrency design philosophy draws from Kotlin's structured concurrency and ZIO's Scope.
50%UnverifiedEffect's dependency injection system is composed of three concepts: Context, Tag, and Layer.
50%UnverifiedCompared to decorator-based DI frameworks such as tsyringe and inversify, Effect's dependency injection operates entirely within the type system, with no runtime metadata dependencies and no need for TypeScript decorator features.
50%UnverifiedEffect V4 merges many previously scattered packages into the core effect package, and includes 17 unstable modules covering HTTP, RPC, CLI, workflows, clustering, and more.
50%UnverifiedEffect uses Fibers (lightweight virtual threads) to implement structured concurrency.
50%UnverifiedEffect is a TypeScript library whose V4 version is in beta.
50%UnverifiedIn Effect error types, bare Error should not be used, because Error is the parent class of all errors and causes the type to collapse; instead, Data.TaggedError should be used to define named errors.
50%UnverifiedIn Effect, if you do not provide the required service to a program that depends on it, the code simply will not compile, rather than failing at runtime.
50%UnverifiedThe core type of Effect is Effect<Success, Error, Requirements>, where the three type parameters represent the success value, possible errors, and the contextual dependencies required for execution.
50%UnverifiedUnlike Promise, which only exposes the resolved value and swallows errors into unknown, Effect forces errors to be written into the type system.
50%UnverifiedEffect is a lazy value that describes a computation; the entire program can be constructed as a tree of effects, and nothing is actually executed until Effect.runMain or another runner is called.
50%UnverifiedEffect's catchTag can precisely narrow error types because each TaggedError carries a _tag field with a literal type that TypeScript's type narrowing mechanism can recognize.
50%UnverifiedThe basic constructors provided by Effect include Effect.succeed, Effect.fail, Effect.sync, Effect.try, Effect.promise, Effect.tryPromise, and Effect.callback.
50%UnverifiedIn Effect's structured concurrency, if one parallel request fails, the other requests are immediately interrupted — this capability is built in.
50%