Import
import { Fx } from "@typed/fx";Access Fx.fn.NonGen 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 NonGen = {
<Args extends Array<any>, ReturnFx extends Fx.Any>(body: (this: unassigned, ...args: Args) => ReturnFx): (...args: Args) => ReturnFx;
<Self, Args extends Array<any>, ReturnFx extends Fx.Any>(body: (this: Self, ...args: Args) => ReturnFx): (this: Self, ...args: Args) => ReturnFx;
<Args extends Array<any>, ReturnFx extends Fx.Any, A>(body: (this: unassigned, ...args: Args) => ReturnFx, a: (_: ReturnFx, ...args: Args) => A): (...args: Args) => A;
<Self, Args extends Array<any>, ReturnFx extends Fx.Any, A>(body: (this: Self, ...args: Args) => ReturnFx, a: (_: ReturnFx, ...args: Args) => A): (this: Self, ...args: Args) => A;
<Args extends Array<any>, ReturnFx extends Fx.Any, A, B>(body: (this: unassigned, ...args: Args) => ReturnFx, a: (_: ReturnFx, ...args: Args) => A, b: (_: A, ...args: Args) => B): (...args: Args) => B;
<Self, Args extends Array<any>, ReturnFx extends Fx.Any, A, B>(body: (this: Self, ...args: Args) => ReturnFx, a: (_: ReturnFx, ...args: Args) => A, b: (_: A, ...args: Args) => B): (this: Self, ...args: Args) => B;
<Args extends Array<any>, ReturnFx extends Fx.Any, A, B, C>(body: (this: unassigned, ...args: Args) => ReturnFx, a: (_: ReturnFx, ...args: Args) => A, b: (_: A, ...args: Args) => B, c: (_: B, ...args: Args) => C): (...args: Args) => C;
<Self, Args extends Array<any>, ReturnFx extends Fx.Any, A, B, C>(body: (this: Self, ...args: Args) => ReturnFx, a: (_: ReturnFx, ...args: Args) => A, b: (_: A, ...args: Args) => B, c: (_: B, ...args: Args) => C): (this: Self, ...args: Args) => C;
};Why
NonGen adds Effect-style tracing and a typed pipeline to ordinary Fx factories
without forcing a generator when no Effect acquisition is needed.
Ownership and lifetime
Defining and invoking the function are both inert. Invocation returns an Fx
without evaluating body; Effect.fn suspends it. Each run evaluates the body
once, then runs its returned producer in that same ownership and interruption
lifetime.
Examples
import { Fx } from "@typed/fx"
let bodyCalls = 0
const greeting = Fx.fn(
(name: string) => {
bodyCalls += 1
return Fx.succeed(name)
},
(source) => Fx.map(source, (name) => `hello ${name}`)
)
const source = greeting("Ada") // bodyCalls is still 0
const program = Fx.collectAll(source) // running program increments bodyCallsOther 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:226packages/fx/src/Fx/constructors/fn.ts:227packages/fx/src/Fx/constructors/fn.ts:230packages/fx/src/Fx/constructors/fn.ts:234packages/fx/src/Fx/constructors/fn.ts:238packages/fx/src/Fx/constructors/fn.ts:243packages/fx/src/Fx/constructors/fn.ts:248packages/fx/src/Fx/constructors/fn.ts:254packages/fx/src/Fx/constructors/fn.ts:260