Skip to content
Effect Days 2026 Get your ticket

Effectable

Low-level helpers for making custom values behave like Effects. The module exposes a prototype builder, an abstract base class, and a mixin that let domain-specific values, such as service keys or configuration descriptions, be evaluated by Effect and yielded inside Effect.gen.

3 exports Added in v2.0.0 Source

Constructors

Class

Added in v2.0.0 Source

Provides an abstract class that can be extended to create an Effect.

When to use

Use as an abstract base class to define custom classes whose instances behave as Effect values.

See

  • Prototype for a lower-level primitive approach to creating custom Effect-like values without a class
  • Mixin for wrapping an existing class constructor

Signature

declare class Class<A, E = never, R = never> extends Base<A, E, R> {
constructor<A, E = never, R = never>();
abstract asEffect(): Effect<A, E, R>;
}

Mixin

Added in v4.0.0 Source

Returns a subclass of the provided class that inserts the Effect prototype into the inheritance chain.

When to use

Use to make instances of an existing class behave as Effect values without extending Class or modifying the original prototype.

Details

Pass the class to wrap, then implement asEffect on the final class. The returned class is abstract, and the success, error, and service types are inferred from the concrete asEffect return type. Concrete and abstract base classes are supported. Constructor parameters and instance members are preserved, except that Effect's prototype members shadow base prototype members with the same name: pipe, toString, toJSON, [Symbol.iterator], and [Symbol.for("nodejs.util.inspect.custom")].

See

  • Prototype for a lower-level primitive approach to creating custom Effect-like values without a class
  • Class for a base constructor to extend

Signature

declare function Mixin<TBase extends (...args: readonly Array<any>) => object>(klass: TBase): TBase & typeof MixinBase

Example

(Evaluating a mixed-in class)

import { Effect, Effectable } from "effect"
class Box {
constructor(readonly value: number) {}
}
class EffectBox extends Effectable.Mixin(Box) {
asEffect() {
return Effect.succeed(this.value)
}
}
const box = new EffectBox(2)
Effect.isEffect(box) // => true
await Effect.runPromise(box) // => 2

Prototypes

Prototype

Added in v4.0.0 Source

Create a low-level Effect prototype.

When to use

Use when you need to create a custom Effect-like value without extending a class, by providing a label and an evaluate function that receives the current fiber.

Details

When the effect is evaluated, it calls evaluate with the current fiber.

See

  • Class for a class-based approach to defining custom Effect values
  • Mixin for wrapping an existing class constructor

Signature

declare function Prototype<A extends Effect<any, any, any>>(options: {
readonly evaluate: (this: A, fiber: Fiber<any, any>) => Effect<Success<A>, Error<A>, Services<A>>;
readonly label: string;
}): Effect<Success<A>, Error<A>, Services<A>>