Import
import { Fx } from "@typed/fx";Access Fx.fn.Gen through the imported Fx export. Its declaration below describes the member.
This public exposure is a re-export. Its import path is supported; declaration documentation is shared with the other public exposures below.
Signatures
type Gen = {
<Eff extends Effect.Effect<any, any, any>, ReturnFx extends Fx.Any, Args extends Array<any>>(body: (this: unassigned, ...args: Args) => Generator<Eff, ReturnFx>): (...args: Args) => Fx<Fx.Success<ReturnFx>, Fx.Error<ReturnFx> | Effect.Error<Eff>, Fx.Services<ReturnFx> | Effect.Services<Eff>>;
<Self, Eff extends Effect.Effect<any, any, any>, ReturnFx extends Fx.Any, Args extends Array<any>>(body: (this: Self, ...args: Args) => Generator<Eff, ReturnFx>): (this: Self, ...args: Args) => Fx<Fx.Success<ReturnFx>, Fx.Error<ReturnFx> | Effect.Error<Eff>, Fx.Services<ReturnFx> | Effect.Services<Eff>>;
<Eff extends Effect.Effect<any, any, any>, ReturnFx extends Fx.Any, Args extends Array<any>, A>(body: (this: unassigned, ...args: Args) => Generator<Eff, ReturnFx>, a: (_: Fx<Fx.Success<ReturnFx>, Fx.Error<ReturnFx> | Effect.Error<Eff>, Fx.Services<ReturnFx> | Effect.Services<Eff>>, ...args: Args) => A): (...args: Args) => A;
<Self, Eff extends Effect.Effect<any, any, any>, ReturnFx extends Fx.Any, Args extends Array<any>, A>(body: (this: Self, ...args: Args) => Generator<Eff, ReturnFx>, a: (_: Fx<Fx.Success<ReturnFx>, Fx.Error<ReturnFx> | Effect.Error<Eff>, Fx.Services<ReturnFx> | Effect.Services<Eff>>, ...args: Args) => A): (this: Self, ...args: Args) => A;
<Eff extends Effect.Effect<any, any, any>, ReturnFx extends Fx.Any, Args extends Array<any>, A, B>(body: (this: unassigned, ...args: Args) => Generator<Eff, ReturnFx>, a: (_: Fx<Fx.Success<ReturnFx>, Fx.Error<ReturnFx> | Effect.Error<Eff>, Fx.Services<ReturnFx> | Effect.Services<Eff>>, ...args: Args) => A, b: (_: A, ...args: Args) => B): (...args: Args) => B;
<Self, Eff extends Effect.Effect<any, any, any>, ReturnFx extends Fx.Any, Args extends Array<any>, A, B>(body: (this: Self, ...args: Args) => Generator<Eff, ReturnFx>, a: (_: Fx<Fx.Success<ReturnFx>, Fx.Error<ReturnFx> | Effect.Error<Eff>, Fx.Services<ReturnFx> | Effect.Services<Eff>>, ...args: Args) => A, b: (_: A, ...args: Args) => B): (this: Self, ...args: Args) => B;
<Eff extends Effect.Effect<any, any, any>, ReturnFx extends Fx.Any, Args extends Array<any>, A, B, C>(body: (this: unassigned, ...args: Args) => Generator<Eff, ReturnFx>, a: (_: Fx<Fx.Success<ReturnFx>, Fx.Error<ReturnFx> | Effect.Error<Eff>, Fx.Services<ReturnFx> | Effect.Services<Eff>>, ...args: Args) => A, b: (_: A, ...args: Args) => B, c: (_: B, ...args: Args) => C): (...args: Args) => C;
<Self, Eff extends Effect.Effect<any, any, any>, ReturnFx extends Fx.Any, Args extends Array<any>, A, B, C>(body: (this: Self, ...args: Args) => Generator<Eff, ReturnFx>, a: (_: Fx<Fx.Success<ReturnFx>, Fx.Error<ReturnFx> | Effect.Error<Eff>, Fx.Services<ReturnFx> | Effect.Services<Eff>>, ...args: Args) => A, b: (_: A, ...args: Args) => B, c: (_: B, ...args: Args) => C): (this: Self, ...args: Args) => C;
};Why
Gen combines services and errors from yielded Effects with those of the returned
Fx, while retaining the original arguments and this type. Optional pipeable
arguments transform the resulting Fx without hiding those channels.
Ownership and lifetime
Defining the function is inert. The body and yielded Effects execute once per run
of the Fx returned by an invocation; that run owns acquisition and interruption.
Examples
import { Effect } from "effect"
import { Fx } from "@typed/fx"
const item = Fx.fn(function* (id: number) {
const prefix = yield* Effect.succeed("item")
return Fx.succeed(`${prefix}:${id}`)
})
const program = Fx.collectAll(item(1))Other public imports
These import paths expose the same declaration. Each page retains its own public name and signature.
Source
packages/fx/src/Fx/constructors/fn.ts:55packages/fx/src/Fx/constructors/fn.ts:56packages/fx/src/Fx/constructors/fn.ts:65packages/fx/src/Fx/constructors/fn.ts:81packages/fx/src/Fx/constructors/fn.ts:92packages/fx/src/Fx/constructors/fn.ts:110packages/fx/src/Fx/constructors/fn.ts:128packages/fx/src/Fx/constructors/fn.ts:148packages/fx/src/Fx/constructors/fn.ts:168