<R, ER>(
layer: Layer.Layer<R, ER, never>,
options?: { readonly memoMap?: Layer.MemoMap | undefined } | undefined
): ManagedRuntime<R, ER>Creates a ManagedRuntime from a layer.
When to use
Use to create a reusable runtime from a Layer for application entry points
or integration code that runs many effects without rebuilding services.
Details
The layer is built lazily on first use and its context is cached for
subsequent runs. Resources acquired by the layer are owned by the runtime and
are released when dispose or disposeEffect is run. options.memoMap can
be used to share layer memoization with other layer builds.
Gotchas
Dispose the runtime when it is no longer needed. A runtime cannot be reused after disposal.
Example (Creating a managed runtime)
import { Context, Effect, Layer, ManagedRuntime } from "effect"
class Notifications extends Context.Service<Notifications, {
readonly notify: (message: string) => Effect.Effect<void>
}>()("Notifications") {
static readonly layer = Layer.succeed(this)({
notify: Effect.fn("Notifications.notify")((message) =>
Effect.sync(() => console.log(message))
)
})
}
const runtime = ManagedRuntime.make(Notifications.layer)
const program = Effect.flatMap(
Notifications,
(_) => _.notify("Hello, world!")
).pipe(Effect.ensuring(runtime.disposeEffect))
runtime.runPromise(program)
// Hello, world!export const const make: <R, ER>(
layer: Layer.Layer<R, ER, never>,
options?:
| {
readonly memoMap?:
| Layer.MemoMap
| undefined
}
| undefined
) => ManagedRuntime<R, ER>
Creates a ManagedRuntime from a layer.
When to use
Use to create a reusable runtime from a Layer for application entry points
or integration code that runs many effects without rebuilding services.
Details
The layer is built lazily on first use and its context is cached for
subsequent runs. Resources acquired by the layer are owned by the runtime and
are released when dispose or disposeEffect is run. options.memoMap can
be used to share layer memoization with other layer builds.
Gotchas
Dispose the runtime when it is no longer needed. A runtime cannot be reused
after disposal.
Example (Creating a managed runtime)
import { Context, Effect, Layer, ManagedRuntime } from "effect"
class Notifications extends Context.Service<Notifications, {
readonly notify: (message: string) => Effect.Effect<void>
}>()("Notifications") {
static readonly layer = Layer.succeed(this)({
notify: Effect.fn("Notifications.notify")((message) =>
Effect.sync(() => console.log(message))
)
})
}
const runtime = ManagedRuntime.make(Notifications.layer)
const program = Effect.flatMap(
Notifications,
(_) => _.notify("Hello, world!")
).pipe(Effect.ensuring(runtime.disposeEffect))
runtime.runPromise(program)
// Hello, world!
make = <function (type parameter) R in <R, ER>(layer: Layer.Layer<R, ER, never>, options?: {
readonly memoMap?: Layer.MemoMap | undefined;
} | undefined): ManagedRuntime<R, ER>
R, function (type parameter) ER in <R, ER>(layer: Layer.Layer<R, ER, never>, options?: {
readonly memoMap?: Layer.MemoMap | undefined;
} | undefined): ManagedRuntime<R, ER>
ER>(
layer: Layer.Layer<R, ER, never>(parameter) layer: {
build: (memoMap: MemoMap, scope: Scope.Scope) => Effect<Context.Context<R>, ER, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
layer: import LayerLayer.type Layer.Layer = /*unresolved*/ anyLayer<function (type parameter) R in <R, ER>(layer: Layer.Layer<R, ER, never>, options?: {
readonly memoMap?: Layer.MemoMap | undefined;
} | undefined): ManagedRuntime<R, ER>
R, function (type parameter) ER in <R, ER>(layer: Layer.Layer<R, ER, never>, options?: {
readonly memoMap?: Layer.MemoMap | undefined;
} | undefined): ManagedRuntime<R, ER>
ER, never>,
options: | {
readonly memoMap?: Layer.MemoMap | undefined
}
| undefined
options?: {
readonly memoMap?: Layer.MemoMap | undefinedmemoMap?: import LayerLayer.type Layer.MemoMap = /*unresolved*/ anyMemoMap | undefined
} | undefined
): interface ManagedRuntime<in R, out ER>Type helpers associated with ManagedRuntime.
When to use
Use to reference type-level helpers for extracting managed runtime services
and layer errors.
A runtime built from a layer that can execute effects requiring that layer's
services.
When to use
Use as the reusable runtime value returned by make when application entry
points or integration code need to run many effects against the same
layer-built services.
Details
The runtime builds and caches its service context and owns the scope for
resources acquired by the layer.
Gotchas
Dispose the runtime with dispose or disposeEffect when it is no longer
needed.
ManagedRuntime<function (type parameter) R in <R, ER>(layer: Layer.Layer<R, ER, never>, options?: {
readonly memoMap?: Layer.MemoMap | undefined;
} | undefined): ManagedRuntime<R, ER>
R, function (type parameter) ER in <R, ER>(layer: Layer.Layer<R, ER, never>, options?: {
readonly memoMap?: Layer.MemoMap | undefined;
} | undefined): ManagedRuntime<R, ER>
ER> => {
const const memoMap: Layer.MemoMapconst memoMap: {
get: <RIn, E, ROut>(layer: Layer<ROut, E, RIn>, scope: Scope.Scope) => Effect<Context.Context<ROut>, E, RIn> | undefined;
getOrElseMemoize: <RIn, E, ROut>(layer: Layer<ROut, E, RIn>, scope: Scope.Scope, build: (memoMap: MemoMap, scope: Scope.Scope) => Effect<Context.Context<ROut>, E, RIn>) => Effect<Context.Context<ROut>, E, RIn>;
}
memoMap = options: | {
readonly memoMap?: Layer.MemoMap | undefined
}
| undefined
options?.memoMap?: Layer.MemoMap | undefinedmemoMap ?? import LayerLayer.makeMemoMapUnsafe()
const const scope: Scope.Closeableconst scope: {
strategy: "sequential" | "parallel";
state: State.Open | State.Closed | State.Empty;
}
scope = import ScopeScope.const makeUnsafe: (
finalizerStrategy?: "sequential" | "parallel"
) => Closeable
Creates a new Scope synchronously without wrapping it in an Effect.
This is useful when you need a scope immediately but should be used with caution
as it doesn't provide the same safety guarantees as the Effect-wrapped version.
When to use
Use when a scope must be allocated synchronously and the caller will close it
manually.
Example (Creating a scope synchronously)
import { Console, Effect, Exit, Scope } from "effect"
// Create a scope immediately
const scope = Scope.makeUnsafe("sequential")
// Use it in an Effect program
const program = Effect.gen(function*() {
yield* Scope.addFinalizer(scope, Console.log("Cleanup"))
yield* Scope.close(scope, Exit.void)
})
makeUnsafe("parallel")
const const layerScope: Scope.Closeableconst layerScope: {
strategy: "sequential" | "parallel";
state: State.Open | State.Closed | State.Empty;
}
layerScope = import ScopeScope.const forkUnsafe: (
scope: Scope,
finalizerStrategy?: "sequential" | "parallel"
) => Closeable
Creates a closeable child scope synchronously and registers it with a parent scope.
When to use
Use when a child scope must be created synchronously and the caller controls
both parent and child scope lifetimes.
Details
Closing the parent closes the child with the same exit value, and closing the
child detaches it from the parent. The optional finalizer strategy configures
the child scope and defaults to "sequential" when omitted.
Example (Creating a child scope synchronously)
import { Console, Effect, Exit, Scope } from "effect"
const program = Effect.gen(function*() {
const parentScope = Scope.makeUnsafe("sequential")
const childScope = Scope.forkUnsafe(parentScope, "parallel")
// Add finalizers to both scopes
yield* Scope.addFinalizer(parentScope, Console.log("Parent cleanup"))
yield* Scope.addFinalizer(childScope, Console.log("Child cleanup"))
// Close child first, then parent
yield* Scope.close(childScope, Exit.void)
yield* Scope.close(parentScope, Exit.void)
})
forkUnsafe(const scope: Scope.Closeableconst scope: {
strategy: "sequential" | "parallel";
state: State.Open | State.Closed | State.Empty;
}
scope, "sequential")
const const defaultRunOptions: Effect.RunOptionsconst defaultRunOptions: {
signal: AbortSignal | undefined;
scheduler: Scheduler | undefined;
uninterruptible: boolean | undefined;
onFiberStart: ((fiber: Fiber<unknown, unknown>) => void) | undefined;
}
defaultRunOptions: import EffectEffect.type Effect.RunOptions = /*unresolved*/ anyRunOptions = {
onFiberStart: <A, E>(self: Fiber<A, E>) => Fiber<A, E>onFiberStart: import FiberFiber.runIn(const scope: Scope.Closeableconst scope: {
strategy: "sequential" | "parallel";
state: State.Open | State.Closed | State.Empty;
}
scope)
}
const const mergeRunOptions: <
O extends Effect.RunOptions
>(
options?: O
) => O
mergeRunOptions = <function (type parameter) O in <O extends Effect.RunOptions>(options?: O): OO extends import EffectEffect.type Effect.RunOptions = /*unresolved*/ anyRunOptions>(options: O | undefinedoptions?: function (type parameter) O in <O extends Effect.RunOptions>(options?: O): OO): function (type parameter) O in <O extends Effect.RunOptions>(options?: O): OO =>
options: O | undefinedoptions
? {
...options: NonNullable<O>options,
onFiberStart: anyonFiberStart: options: NonNullable<O>options.onFiberStart ?
(fiber: Fiber.Fiber<unknown, unknown>(parameter) fiber: {
id: number;
currentOpCount: number;
getRef: <A>(ref: Context.Reference<A>) => A;
context: Context.Context<never>;
setContext: (context: Context.Context<never>) => void;
currentScheduler: Scheduler;
currentDispatcher: SchedulerDispatcher;
currentSpan: AnySpan | undefined;
currentLogLevel: LogLevel;
minimumLogLevel: LogLevel;
currentStackFrame: StackFrame | undefined;
maxOpsBeforeYield: number;
currentPreventYield: boolean;
addObserver: (cb: (exit: Exit<A, E>) => void) => () => void;
interruptUnsafe: (fiberId?: number | undefined, annotations?: Context.Context<never> | undefined) => void;
pollUnsafe: () => Exit<A, E> | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
fiber) => {
const defaultRunOptions: Effect.RunOptionsconst defaultRunOptions: {
signal: AbortSignal | undefined;
scheduler: Scheduler | undefined;
uninterruptible: boolean | undefined;
onFiberStart: ((fiber: Fiber<unknown, unknown>) => void) | undefined;
}
defaultRunOptions.onFiberStart!(fiber: Fiber.Fiber<unknown, unknown>(parameter) fiber: {
id: number;
currentOpCount: number;
getRef: <A>(ref: Context.Reference<A>) => A;
context: Context.Context<never>;
setContext: (context: Context.Context<never>) => void;
currentScheduler: Scheduler;
currentDispatcher: SchedulerDispatcher;
currentSpan: AnySpan | undefined;
currentLogLevel: LogLevel;
minimumLogLevel: LogLevel;
currentStackFrame: StackFrame | undefined;
maxOpsBeforeYield: number;
currentPreventYield: boolean;
addObserver: (cb: (exit: Exit<A, E>) => void) => () => void;
interruptUnsafe: (fiberId?: number | undefined, annotations?: Context.Context<never> | undefined) => void;
pollUnsafe: () => Exit<A, E> | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
fiber)
options: NonNullable<O>options.onFiberStart!(fiber: Fiber.Fiber<unknown, unknown>(parameter) fiber: {
id: number;
currentOpCount: number;
getRef: <A>(ref: Context.Reference<A>) => A;
context: Context.Context<never>;
setContext: (context: Context.Context<never>) => void;
currentScheduler: Scheduler;
currentDispatcher: SchedulerDispatcher;
currentSpan: AnySpan | undefined;
currentLogLevel: LogLevel;
minimumLogLevel: LogLevel;
currentStackFrame: StackFrame | undefined;
maxOpsBeforeYield: number;
currentPreventYield: boolean;
addObserver: (cb: (exit: Exit<A, E>) => void) => () => void;
interruptUnsafe: (fiberId?: number | undefined, annotations?: Context.Context<never> | undefined) => void;
pollUnsafe: () => Exit<A, E> | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
fiber)
} :
const defaultRunOptions: Effect.RunOptionsconst defaultRunOptions: {
signal: AbortSignal | undefined;
scheduler: Scheduler | undefined;
uninterruptible: boolean | undefined;
onFiberStart: ((fiber: Fiber<unknown, unknown>) => void) | undefined;
}
defaultRunOptions.onFiberStart
}
: const defaultRunOptions: Effect.RunOptionsconst defaultRunOptions: {
signal: AbortSignal | undefined;
scheduler: Scheduler | undefined;
uninterruptible: boolean | undefined;
onFiberStart: ((fiber: Fiber<unknown, unknown>) => void) | undefined;
}
defaultRunOptions as function (type parameter) O in <O extends Effect.RunOptions>(options?: O): OO
let let buildFiber:
| Fiber.Fiber<Context.Context<R>, ER>
| undefined
buildFiber: import FiberFiber.type Fiber.Fiber = /*unresolved*/ anyFiber<import ContextContext.type Context.Context = /*unresolved*/ anyContext<function (type parameter) R in <R, ER>(layer: Layer.Layer<R, ER, never>, options?: {
readonly memoMap?: Layer.MemoMap | undefined;
} | undefined): ManagedRuntime<R, ER>
R>, function (type parameter) ER in <R, ER>(layer: Layer.Layer<R, ER, never>, options?: {
readonly memoMap?: Layer.MemoMap | undefined;
} | undefined): ManagedRuntime<R, ER>
ER> | undefined
const const contextEffect: Effect.Effect<
Context.Context<R>,
ER,
never
>
const contextEffect: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
contextEffect = import EffectEffect.withFiber<import ContextContext.type Context.Context = /*unresolved*/ anyContext<function (type parameter) R in <R, ER>(layer: Layer.Layer<R, ER, never>, options?: {
readonly memoMap?: Layer.MemoMap | undefined;
} | undefined): ManagedRuntime<R, ER>
R>, function (type parameter) ER in <R, ER>(layer: Layer.Layer<R, ER, never>, options?: {
readonly memoMap?: Layer.MemoMap | undefined;
} | undefined): ManagedRuntime<R, ER>
ER>((fiber: Fiber.Fiber<unknown, unknown>(parameter) fiber: {
id: number;
currentOpCount: number;
getRef: <A>(ref: Context.Reference<A>) => A;
context: Context.Context<never>;
setContext: (context: Context.Context<never>) => void;
currentScheduler: Scheduler;
currentDispatcher: SchedulerDispatcher;
currentSpan: AnySpan | undefined;
currentLogLevel: LogLevel;
minimumLogLevel: LogLevel;
currentStackFrame: StackFrame | undefined;
maxOpsBeforeYield: number;
currentPreventYield: boolean;
addObserver: (cb: (exit: Exit<A, E>) => void) => () => void;
interruptUnsafe: (fiberId?: number | undefined, annotations?: Context.Context<never> | undefined) => void;
pollUnsafe: () => Exit<A, E> | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
fiber) => {
if (!let buildFiber:
| Fiber.Fiber<Context.Context<R>, ER>
| undefined
buildFiber) {
let buildFiber:
| Fiber.Fiber<Context.Context<R>, ER>
| undefined
buildFiber = import EffectEffect.runFork(
import EffectEffect.tap(
import LayerLayer.buildWithMemoMap(layer: Layer.Layer<R, ER, never>(parameter) layer: {
build: (memoMap: MemoMap, scope: Scope.Scope) => Effect<Context.Context<R>, ER, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
layer, const memoMap: Layer.MemoMapconst memoMap: {
get: <RIn, E, ROut>(layer: Layer<ROut, E, RIn>, scope: Scope.Scope) => Effect<Context.Context<ROut>, E, RIn> | undefined;
getOrElseMemoize: <RIn, E, ROut>(layer: Layer<ROut, E, RIn>, scope: Scope.Scope, build: (memoMap: MemoMap, scope: Scope.Scope) => Effect<Context.Context<ROut>, E, RIn>) => Effect<Context.Context<ROut>, E, RIn>;
}
memoMap, const layerScope: Scope.Closeableconst layerScope: {
strategy: "sequential" | "parallel";
state: State.Open | State.Closed | State.Empty;
}
layerScope),
(context: Context.Context<R>(parameter) context: {
mapUnsafe: ReadonlyMap<string, any>;
mutable: boolean;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
context) =>
import EffectEffect.sync(() => {
const self: ManagedRuntime<R, ER>const self: {
memoMap: Layer.MemoMap;
contextEffect: Effect.Effect<Context.Context<R>, ER>;
context: () => Promise<Context.Context<R>>;
scope: Scope.Closeable;
cachedContext: Context.Context<R> | undefined;
runFork: <A, E>(self: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Fiber.Fiber<A, E | ER>;
runSyncExit: <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, ER | E>;
runSync: <A, E>(effect: Effect.Effect<A, E, R>) => A;
runCallback: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & { readonly onExit: (exit: Exit.Exit<A, E | ER>) => void } | undefined) => (interruptor?: number | undefined) => void;
runPromise: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<A>;
runPromiseExit: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<Exit.Exit<A, ER | E>>;
dispose: () => Promise<void>;
disposeEffect: Effect.Effect<void, never, never>;
}
self.ManagedRuntime<in R, out ER>.cachedContext: Context.Context<R> | undefinedcachedContext = context: Context.Context<R>(parameter) context: {
mapUnsafe: ReadonlyMap<string, any>;
mutable: boolean;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
context
})
),
{ ...const defaultRunOptions: Effect.RunOptionsconst defaultRunOptions: {
signal: AbortSignal | undefined;
scheduler: Scheduler | undefined;
uninterruptible: boolean | undefined;
onFiberStart: ((fiber: Fiber<unknown, unknown>) => void) | undefined;
}
defaultRunOptions, scheduler: Scheduler(property) scheduler: {
executionMode: "sync" | "async";
shouldYield: (fiber: Fiber.Fiber<unknown, unknown>) => boolean;
makeDispatcher: () => SchedulerDispatcher;
}
scheduler: fiber: Fiber.Fiber<unknown, unknown>(parameter) fiber: {
id: number;
currentOpCount: number;
getRef: <A>(ref: Context.Reference<A>) => A;
context: Context.Context<never>;
setContext: (context: Context.Context<never>) => void;
currentScheduler: Scheduler;
currentDispatcher: SchedulerDispatcher;
currentSpan: AnySpan | undefined;
currentLogLevel: LogLevel;
minimumLogLevel: LogLevel;
currentStackFrame: StackFrame | undefined;
maxOpsBeforeYield: number;
currentPreventYield: boolean;
addObserver: (cb: (exit: Exit<A, E>) => void) => () => void;
interruptUnsafe: (fiberId?: number | undefined, annotations?: Context.Context<never> | undefined) => void;
pollUnsafe: () => Exit<A, E> | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
fiber.currentScheduler }
)
}
return import EffectEffect.flatten(import FiberFiber.await(let buildFiber:
| Fiber.Fiber<Context.Context<R>, ER>
| undefined
let buildFiber: {
id: number;
currentOpCount: number;
getRef: <A>(ref: Context.Reference<A>) => A;
context: Context.Context<never>;
setContext: (context: Context.Context<never>) => void;
currentScheduler: Scheduler;
currentDispatcher: SchedulerDispatcher;
currentSpan: AnySpan | undefined;
currentLogLevel: LogLevel;
minimumLogLevel: LogLevel;
currentStackFrame: StackFrame | undefined;
maxOpsBeforeYield: number;
currentPreventYield: boolean;
addObserver: (cb: (exit: Exit<A, E>) => void) => () => void;
interruptUnsafe: (fiberId?: number | undefined, annotations?: Context.Context<never> | undefined) => void;
pollUnsafe: () => Exit<A, E> | undefined;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
buildFiber))
})
const const self: ManagedRuntime<R, ER>const self: {
memoMap: Layer.MemoMap;
contextEffect: Effect.Effect<Context.Context<R>, ER>;
context: () => Promise<Context.Context<R>>;
scope: Scope.Closeable;
cachedContext: Context.Context<R> | undefined;
runFork: <A, E>(self: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Fiber.Fiber<A, E | ER>;
runSyncExit: <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, ER | E>;
runSync: <A, E>(effect: Effect.Effect<A, E, R>) => A;
runCallback: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & { readonly onExit: (exit: Exit.Exit<A, E | ER>) => void } | undefined) => (interruptor?: number | undefined) => void;
runPromise: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<A>;
runPromiseExit: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<Exit.Exit<A, ER | E>>;
dispose: () => Promise<void>;
disposeEffect: Effect.Effect<void, never, never>;
}
self: interface ManagedRuntime<in R, out ER>Type helpers associated with ManagedRuntime.
When to use
Use to reference type-level helpers for extracting managed runtime services
and layer errors.
A runtime built from a layer that can execute effects requiring that layer's
services.
When to use
Use as the reusable runtime value returned by make when application entry
points or integration code need to run many effects against the same
layer-built services.
Details
The runtime builds and caches its service context and owns the scope for
resources acquired by the layer.
Gotchas
Dispose the runtime with dispose or disposeEffect when it is no longer
needed.
ManagedRuntime<function (type parameter) R in <R, ER>(layer: Layer.Layer<R, ER, never>, options?: {
readonly memoMap?: Layer.MemoMap | undefined;
} | undefined): ManagedRuntime<R, ER>
R, function (type parameter) ER in <R, ER>(layer: Layer.Layer<R, ER, never>, options?: {
readonly memoMap?: Layer.MemoMap | undefined;
} | undefined): ManagedRuntime<R, ER>
ER> = {
[const TypeId: "~effect/ManagedRuntime"TypeId]: const TypeId: "~effect/ManagedRuntime"TypeId,
ManagedRuntime<in R, out ER>.memoMap: Layer.MemoMap(property) ManagedRuntime<in R, out ER>.memoMap: {
get: <RIn, E, ROut>(layer: Layer<ROut, E, RIn>, scope: Scope.Scope) => Effect<Context.Context<ROut>, E, RIn> | undefined;
getOrElseMemoize: <RIn, E, ROut>(layer: Layer<ROut, E, RIn>, scope: Scope.Scope, build: (memoMap: MemoMap, scope: Scope.Scope) => Effect<Context.Context<ROut>, E, RIn>) => Effect<Context.Context<ROut>, E, RIn>;
}
memoMap,
ManagedRuntime<in R, out ER>.scope: Scope.Closeable(property) ManagedRuntime<in R, out ER>.scope: {
strategy: "sequential" | "parallel";
state: State.Open | State.Closed | State.Empty;
}
scope,
ManagedRuntime<in R, out ER>.contextEffect: Effect.Effect<Context.Context<R>, ER, never>(property) ManagedRuntime<in R, out ER>.contextEffect: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
contextEffect: const contextEffect: Effect.Effect<
Context.Context<R>,
ER,
never
>
const contextEffect: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
contextEffect,
ManagedRuntime<in R, out ER>.cachedContext: anycachedContext: var undefinedundefined,
ManagedRuntime<R, ER>.context: () => Promise<Context.Context<R>>context() {
return const self: ManagedRuntime<R, ER>const self: {
memoMap: Layer.MemoMap;
contextEffect: Effect.Effect<Context.Context<R>, ER>;
context: () => Promise<Context.Context<R>>;
scope: Scope.Closeable;
cachedContext: Context.Context<R> | undefined;
runFork: <A, E>(self: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Fiber.Fiber<A, E | ER>;
runSyncExit: <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, ER | E>;
runSync: <A, E>(effect: Effect.Effect<A, E, R>) => A;
runCallback: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & { readonly onExit: (exit: Exit.Exit<A, E | ER>) => void } | undefined) => (interruptor?: number | undefined) => void;
runPromise: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<A>;
runPromiseExit: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<Exit.Exit<A, ER | E>>;
dispose: () => Promise<void>;
disposeEffect: Effect.Effect<void, never, never>;
}
self.ManagedRuntime<in R, out ER>.cachedContext: Context.Context<R> | undefinedcachedContext === var undefinedundefined ?
import EffectEffect.runPromise(const self: ManagedRuntime<R, ER>const self: {
memoMap: Layer.MemoMap;
contextEffect: Effect.Effect<Context.Context<R>, ER>;
context: () => Promise<Context.Context<R>>;
scope: Scope.Closeable;
cachedContext: Context.Context<R> | undefined;
runFork: <A, E>(self: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Fiber.Fiber<A, E | ER>;
runSyncExit: <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, ER | E>;
runSync: <A, E>(effect: Effect.Effect<A, E, R>) => A;
runCallback: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & { readonly onExit: (exit: Exit.Exit<A, E | ER>) => void } | undefined) => (interruptor?: number | undefined) => void;
runPromise: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<A>;
runPromiseExit: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<Exit.Exit<A, ER | E>>;
dispose: () => Promise<void>;
disposeEffect: Effect.Effect<void, never, never>;
}
self.ManagedRuntime<in R, out ER>.contextEffect: Effect.Effect<Context.Context<R>, ER>(property) ManagedRuntime<in R, out ER>.contextEffect: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
contextEffect) :
var Promise: PromiseConstructorRepresents the completion of an asynchronous operation
Promise.PromiseConstructor.resolve<any>(value: any): Promise<any> (+2 overloads)Creates a new resolved promise for the provided value.
resolve(const self: ManagedRuntime<R, ER>const self: {
memoMap: Layer.MemoMap;
contextEffect: Effect.Effect<Context.Context<R>, ER>;
context: () => Promise<Context.Context<R>>;
scope: Scope.Closeable;
cachedContext: Context.Context<R> | undefined;
runFork: <A, E>(self: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Fiber.Fiber<A, E | ER>;
runSyncExit: <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, ER | E>;
runSync: <A, E>(effect: Effect.Effect<A, E, R>) => A;
runCallback: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & { readonly onExit: (exit: Exit.Exit<A, E | ER>) => void } | undefined) => (interruptor?: number | undefined) => void;
runPromise: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<A>;
runPromiseExit: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<Exit.Exit<A, ER | E>>;
dispose: () => Promise<void>;
disposeEffect: Effect.Effect<void, never, never>;
}
self.ManagedRuntime<in R, out ER>.cachedContext: Context.Context<R> | undefined(property) ManagedRuntime<in R, out ER>.cachedContext: {
mapUnsafe: ReadonlyMap<string, any>;
mutable: boolean;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
cachedContext)
},
ManagedRuntime<R, ER>.dispose: () => Promise<void>Dispose of the resources associated with the runtime.
When to use
Use to release this runtime's layer resources from Promise-based code.
dispose(): interface Promise<T>Represents the completion of an asynchronous operation
Promise<void> {
return import EffectEffect.runPromise(const self: ManagedRuntime<R, ER>const self: {
memoMap: Layer.MemoMap;
contextEffect: Effect.Effect<Context.Context<R>, ER>;
context: () => Promise<Context.Context<R>>;
scope: Scope.Closeable;
cachedContext: Context.Context<R> | undefined;
runFork: <A, E>(self: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Fiber.Fiber<A, E | ER>;
runSyncExit: <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, ER | E>;
runSync: <A, E>(effect: Effect.Effect<A, E, R>) => A;
runCallback: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & { readonly onExit: (exit: Exit.Exit<A, E | ER>) => void } | undefined) => (interruptor?: number | undefined) => void;
runPromise: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<A>;
runPromiseExit: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<Exit.Exit<A, ER | E>>;
dispose: () => Promise<void>;
disposeEffect: Effect.Effect<void, never, never>;
}
self.ManagedRuntime<in R, out ER>.disposeEffect: Effect.Effect<void, never, never>(property) ManagedRuntime<in R, out ER>.disposeEffect: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
Dispose of the resources associated with the runtime.
When to use
Use to release this runtime's layer resources from an Effect workflow.
disposeEffect)
},
ManagedRuntime<in R, out ER>.disposeEffect: Effect.Effect<void, never, never>(property) ManagedRuntime<in R, out ER>.disposeEffect: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
Dispose of the resources associated with the runtime.
When to use
Use to release this runtime's layer resources from an Effect workflow.
disposeEffect: import EffectEffect.suspend(() => {
;(const self: ManagedRuntime<R, ER>const self: {
memoMap: Layer.MemoMap;
contextEffect: Effect.Effect<Context.Context<R>, ER>;
context: () => Promise<Context.Context<R>>;
scope: Scope.Closeable;
cachedContext: Context.Context<R> | undefined;
runFork: <A, E>(self: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Fiber.Fiber<A, E | ER>;
runSyncExit: <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, ER | E>;
runSync: <A, E>(effect: Effect.Effect<A, E, R>) => A;
runCallback: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & { readonly onExit: (exit: Exit.Exit<A, E | ER>) => void } | undefined) => (interruptor?: number | undefined) => void;
runPromise: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<A>;
runPromiseExit: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<Exit.Exit<A, ER | E>>;
dispose: () => Promise<void>;
disposeEffect: Effect.Effect<void, never, never>;
}
self as type Mutable<T> = { -readonly [P in keyof T]: T[P]; }Removes readonly from all properties of T. Supports arrays, tuples,
and records.
When to use
Use when you need a mutable version of a readonly type.
Details
Only affects the top level; nested properties remain readonly.
Example (Converting shallowly to mutable types)
import type { Types } from "effect"
type Obj = Types.Mutable<{
readonly a: string
readonly b: ReadonlyArray<number>
}>
// { a: string; b: ReadonlyArray<number> }
// ^ mutable ^ still readonly inside
type Arr = Types.Mutable<ReadonlyArray<string>>
// string[]
type Tup = Types.Mutable<readonly [string, number]>
// [string, number]
Mutable<interface ManagedRuntime<in R, out ER>Type helpers associated with ManagedRuntime.
When to use
Use to reference type-level helpers for extracting managed runtime services
and layer errors.
A runtime built from a layer that can execute effects requiring that layer's
services.
When to use
Use as the reusable runtime value returned by make when application entry
points or integration code need to run many effects against the same
layer-built services.
Details
The runtime builds and caches its service context and owns the scope for
resources acquired by the layer.
Gotchas
Dispose the runtime with dispose or disposeEffect when it is no longer
needed.
ManagedRuntime<function (type parameter) R in <R, ER>(layer: Layer.Layer<R, ER, never>, options?: {
readonly memoMap?: Layer.MemoMap | undefined;
} | undefined): ManagedRuntime<R, ER>
R, function (type parameter) ER in <R, ER>(layer: Layer.Layer<R, ER, never>, options?: {
readonly memoMap?: Layer.MemoMap | undefined;
} | undefined): ManagedRuntime<R, ER>
ER>>).contextEffect: Effect.Effect<
Context.Context<R>,
ER,
never
>
(property) contextEffect: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
contextEffect = import EffectEffect.die("ManagedRuntime disposed")
const self: ManagedRuntime<R, ER>const self: {
memoMap: Layer.MemoMap;
contextEffect: Effect.Effect<Context.Context<R>, ER>;
context: () => Promise<Context.Context<R>>;
scope: Scope.Closeable;
cachedContext: Context.Context<R> | undefined;
runFork: <A, E>(self: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Fiber.Fiber<A, E | ER>;
runSyncExit: <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, ER | E>;
runSync: <A, E>(effect: Effect.Effect<A, E, R>) => A;
runCallback: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & { readonly onExit: (exit: Exit.Exit<A, E | ER>) => void } | undefined) => (interruptor?: number | undefined) => void;
runPromise: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<A>;
runPromiseExit: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<Exit.Exit<A, ER | E>>;
dispose: () => Promise<void>;
disposeEffect: Effect.Effect<void, never, never>;
}
self.ManagedRuntime<in R, out ER>.cachedContext: Context.Context<R> | undefinedcachedContext = var undefinedundefined
return import ScopeScope.const close: <A, E>(
self: Scope,
exit: Exit<A, E>
) => Effect<void>
Closes a scope and runs its registered finalizers.
When to use
Use to close a scope manually with a specific exit value.
Details
Finalizers run in the scope's configured order and receive the supplied
Exit.
Example (Running scope finalizers)
import { Console, Effect, Exit, Scope } from "effect"
const resourceManagement = Effect.gen(function*() {
const scope = yield* Scope.make("sequential")
// Add multiple finalizers
yield* Scope.addFinalizer(scope, Console.log("Close database connection"))
yield* Scope.addFinalizer(scope, Console.log("Close file handle"))
yield* Scope.addFinalizer(scope, Console.log("Release memory"))
// Do some work...
yield* Console.log("Performing operations...")
// Close scope - finalizers run in reverse order of registration
yield* Scope.close(scope, Exit.succeed("Success!"))
// Output: "Release memory", "Close file handle", "Close database connection"
})
close(const self: ManagedRuntime<R, ER>const self: {
memoMap: Layer.MemoMap;
contextEffect: Effect.Effect<Context.Context<R>, ER>;
context: () => Promise<Context.Context<R>>;
scope: Scope.Closeable;
cachedContext: Context.Context<R> | undefined;
runFork: <A, E>(self: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Fiber.Fiber<A, E | ER>;
runSyncExit: <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, ER | E>;
runSync: <A, E>(effect: Effect.Effect<A, E, R>) => A;
runCallback: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & { readonly onExit: (exit: Exit.Exit<A, E | ER>) => void } | undefined) => (interruptor?: number | undefined) => void;
runPromise: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<A>;
runPromiseExit: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<Exit.Exit<A, ER | E>>;
dispose: () => Promise<void>;
disposeEffect: Effect.Effect<void, never, never>;
}
self.ManagedRuntime<in R, out ER>.scope: Scope.Closeable(property) ManagedRuntime<in R, out ER>.scope: {
strategy: "sequential" | "parallel";
state: State.Open | State.Closed | State.Empty;
}
scope, import ExitExit.void)
}),
ManagedRuntime<R, ER>.runFork: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Fiber.Fiber<A, E | ER>Executes the effect using the provided Scheduler or using the global
Scheduler if not provided
When to use
Use to fork an effect against this runtime's services and get the running
fiber.
runFork<function (type parameter) A in runFork<A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions): Fiber.Fiber<A, E | ER>A, function (type parameter) E in runFork<A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions): Fiber.Fiber<A, E | ER>E>(effect: Effect.Effect<A, E, R>(parameter) effect: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
effect: import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<function (type parameter) A in runFork<A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions): Fiber.Fiber<A, E | ER>A, function (type parameter) E in runFork<A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions): Fiber.Fiber<A, E | ER>E, function (type parameter) R in <R, ER>(layer: Layer.Layer<R, ER, never>, options?: {
readonly memoMap?: Layer.MemoMap | undefined;
} | undefined): ManagedRuntime<R, ER>
R>, options: Effect.RunOptionsoptions?: import EffectEffect.type Effect.RunOptions = /*unresolved*/ anyRunOptions): import FiberFiber.type Fiber.Fiber = /*unresolved*/ anyFiber<function (type parameter) A in runFork<A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions): Fiber.Fiber<A, E | ER>A, function (type parameter) E in runFork<A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions): Fiber.Fiber<A, E | ER>E | function (type parameter) ER in <R, ER>(layer: Layer.Layer<R, ER, never>, options?: {
readonly memoMap?: Layer.MemoMap | undefined;
} | undefined): ManagedRuntime<R, ER>
ER> {
return const self: ManagedRuntime<R, ER>const self: {
memoMap: Layer.MemoMap;
contextEffect: Effect.Effect<Context.Context<R>, ER>;
context: () => Promise<Context.Context<R>>;
scope: Scope.Closeable;
cachedContext: Context.Context<R> | undefined;
runFork: <A, E>(self: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Fiber.Fiber<A, E | ER>;
runSyncExit: <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, ER | E>;
runSync: <A, E>(effect: Effect.Effect<A, E, R>) => A;
runCallback: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & { readonly onExit: (exit: Exit.Exit<A, E | ER>) => void } | undefined) => (interruptor?: number | undefined) => void;
runPromise: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<A>;
runPromiseExit: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<Exit.Exit<A, ER | E>>;
dispose: () => Promise<void>;
disposeEffect: Effect.Effect<void, never, never>;
}
self.ManagedRuntime<in R, out ER>.cachedContext: Context.Context<R> | undefinedcachedContext === var undefinedundefined ?
import EffectEffect.runFork(function provide<R, ER, A, E>(
managed: ManagedRuntime<R, ER>,
effect: Effect.Effect<A, E, R>
): Effect.Effect<A, E | ER>
provide(const self: ManagedRuntime<R, ER>const self: {
memoMap: Layer.MemoMap;
contextEffect: Effect.Effect<Context.Context<R>, ER>;
context: () => Promise<Context.Context<R>>;
scope: Scope.Closeable;
cachedContext: Context.Context<R> | undefined;
runFork: <A, E>(self: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Fiber.Fiber<A, E | ER>;
runSyncExit: <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, ER | E>;
runSync: <A, E>(effect: Effect.Effect<A, E, R>) => A;
runCallback: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & { readonly onExit: (exit: Exit.Exit<A, E | ER>) => void } | undefined) => (interruptor?: number | undefined) => void;
runPromise: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<A>;
runPromiseExit: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<Exit.Exit<A, ER | E>>;
dispose: () => Promise<void>;
disposeEffect: Effect.Effect<void, never, never>;
}
self, effect: Effect.Effect<A, E, R>(parameter) effect: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
effect), const mergeRunOptions: <
O extends Effect.RunOptions
>(
options?: O
) => O
mergeRunOptions(options: Effect.RunOptionsoptions)) :
import EffectEffect.runForkWith(const self: ManagedRuntime<R, ER>const self: {
memoMap: Layer.MemoMap;
contextEffect: Effect.Effect<Context.Context<R>, ER>;
context: () => Promise<Context.Context<R>>;
scope: Scope.Closeable;
cachedContext: Context.Context<R> | undefined;
runFork: <A, E>(self: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Fiber.Fiber<A, E | ER>;
runSyncExit: <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, ER | E>;
runSync: <A, E>(effect: Effect.Effect<A, E, R>) => A;
runCallback: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & { readonly onExit: (exit: Exit.Exit<A, E | ER>) => void } | undefined) => (interruptor?: number | undefined) => void;
runPromise: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<A>;
runPromiseExit: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<Exit.Exit<A, ER | E>>;
dispose: () => Promise<void>;
disposeEffect: Effect.Effect<void, never, never>;
}
self.ManagedRuntime<in R, out ER>.cachedContext: Context.Context<R> | undefined(property) ManagedRuntime<in R, out ER>.cachedContext: {
mapUnsafe: ReadonlyMap<string, any>;
mutable: boolean;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
cachedContext)(effect: Effect.Effect<A, E, R>(parameter) effect: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
effect, const mergeRunOptions: <
O extends Effect.RunOptions
>(
options?: O
) => O
mergeRunOptions(options: Effect.RunOptionsoptions))
},
ManagedRuntime<R, ER>.runCallback: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & { readonly onExit: (exit: Exit.Exit<A, E | ER>) => void }) => (interruptor?: number | undefined) => voidExecutes the effect asynchronously, eventually passing the exit value to
the specified callback.
When to use
Use when invoking this effectful method at the edges of your
program.
runCallback<function (type parameter) A in runCallback<A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & {
readonly onExit: (exit: Exit.Exit<A, E | ER>) => void;
}): (interruptor?: number | undefined) => void
A, function (type parameter) E in runCallback<A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & {
readonly onExit: (exit: Exit.Exit<A, E | ER>) => void;
}): (interruptor?: number | undefined) => void
E>(
effect: Effect.Effect<A, E, R>(parameter) effect: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
effect: import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<function (type parameter) A in runCallback<A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & {
readonly onExit: (exit: Exit.Exit<A, E | ER>) => void;
}): (interruptor?: number | undefined) => void
A, function (type parameter) E in runCallback<A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & {
readonly onExit: (exit: Exit.Exit<A, E | ER>) => void;
}): (interruptor?: number | undefined) => void
E, function (type parameter) R in <R, ER>(layer: Layer.Layer<R, ER, never>, options?: {
readonly memoMap?: Layer.MemoMap | undefined;
} | undefined): ManagedRuntime<R, ER>
R>,
options: Effect.RunOptions & {
readonly onExit: (
exit: Exit.Exit<A, E | ER>
) => void
}
options?: import EffectEffect.type Effect.RunOptions = /*unresolved*/ anyRunOptions & {
readonly onExit: (exit: Exit.Exit<A, E | ER>) => voidonExit: (exit: Exit.Exit<A, E | ER>exit: import ExitExit.type Exit.Exit = /*unresolved*/ anyExit<function (type parameter) A in runCallback<A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & {
readonly onExit: (exit: Exit.Exit<A, E | ER>) => void;
}): (interruptor?: number | undefined) => void
A, function (type parameter) E in runCallback<A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & {
readonly onExit: (exit: Exit.Exit<A, E | ER>) => void;
}): (interruptor?: number | undefined) => void
E | function (type parameter) ER in <R, ER>(layer: Layer.Layer<R, ER, never>, options?: {
readonly memoMap?: Layer.MemoMap | undefined;
} | undefined): ManagedRuntime<R, ER>
ER>) => void
}
): (interruptor: number | undefinedinterruptor?: number | undefined) => void {
return const self: ManagedRuntime<R, ER>const self: {
memoMap: Layer.MemoMap;
contextEffect: Effect.Effect<Context.Context<R>, ER>;
context: () => Promise<Context.Context<R>>;
scope: Scope.Closeable;
cachedContext: Context.Context<R> | undefined;
runFork: <A, E>(self: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Fiber.Fiber<A, E | ER>;
runSyncExit: <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, ER | E>;
runSync: <A, E>(effect: Effect.Effect<A, E, R>) => A;
runCallback: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & { readonly onExit: (exit: Exit.Exit<A, E | ER>) => void } | undefined) => (interruptor?: number | undefined) => void;
runPromise: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<A>;
runPromiseExit: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<Exit.Exit<A, ER | E>>;
dispose: () => Promise<void>;
disposeEffect: Effect.Effect<void, never, never>;
}
self.ManagedRuntime<in R, out ER>.cachedContext: Context.Context<R> | undefinedcachedContext === var undefinedundefined ?
import EffectEffect.runCallback(function provide<R, ER, A, E>(
managed: ManagedRuntime<R, ER>,
effect: Effect.Effect<A, E, R>
): Effect.Effect<A, E | ER>
provide(const self: ManagedRuntime<R, ER>const self: {
memoMap: Layer.MemoMap;
contextEffect: Effect.Effect<Context.Context<R>, ER>;
context: () => Promise<Context.Context<R>>;
scope: Scope.Closeable;
cachedContext: Context.Context<R> | undefined;
runFork: <A, E>(self: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Fiber.Fiber<A, E | ER>;
runSyncExit: <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, ER | E>;
runSync: <A, E>(effect: Effect.Effect<A, E, R>) => A;
runCallback: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & { readonly onExit: (exit: Exit.Exit<A, E | ER>) => void } | undefined) => (interruptor?: number | undefined) => void;
runPromise: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<A>;
runPromiseExit: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<Exit.Exit<A, ER | E>>;
dispose: () => Promise<void>;
disposeEffect: Effect.Effect<void, never, never>;
}
self, effect: Effect.Effect<A, E, R>(parameter) effect: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
effect), const mergeRunOptions: <
O extends Effect.RunOptions
>(
options?: O
) => O
mergeRunOptions(options: Effect.RunOptions & {
readonly onExit: (
exit: Exit.Exit<A, E | ER>
) => void
}
options)) :
import EffectEffect.runCallbackWith(const self: ManagedRuntime<R, ER>const self: {
memoMap: Layer.MemoMap;
contextEffect: Effect.Effect<Context.Context<R>, ER>;
context: () => Promise<Context.Context<R>>;
scope: Scope.Closeable;
cachedContext: Context.Context<R> | undefined;
runFork: <A, E>(self: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Fiber.Fiber<A, E | ER>;
runSyncExit: <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, ER | E>;
runSync: <A, E>(effect: Effect.Effect<A, E, R>) => A;
runCallback: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & { readonly onExit: (exit: Exit.Exit<A, E | ER>) => void } | undefined) => (interruptor?: number | undefined) => void;
runPromise: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<A>;
runPromiseExit: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<Exit.Exit<A, ER | E>>;
dispose: () => Promise<void>;
disposeEffect: Effect.Effect<void, never, never>;
}
self.ManagedRuntime<in R, out ER>.cachedContext: Context.Context<R> | undefined(property) ManagedRuntime<in R, out ER>.cachedContext: {
mapUnsafe: ReadonlyMap<string, any>;
mutable: boolean;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
cachedContext)(effect: Effect.Effect<A, E, R>(parameter) effect: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
effect, const mergeRunOptions: <
O extends Effect.RunOptions
>(
options?: O
) => O
mergeRunOptions(options: Effect.RunOptions & {
readonly onExit: (
exit: Exit.Exit<A, E | ER>
) => void
}
options))
},
ManagedRuntime<R, ER>.runSyncExit: <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, E | ER>Executes the effect synchronously returning the exit.
When to use
Use when invoking this effectful method at the edges of your
program.
runSyncExit<function (type parameter) A in runSyncExit<A, E>(effect: Effect.Effect<A, E, R>): Exit.Exit<A, E | ER>A, function (type parameter) E in runSyncExit<A, E>(effect: Effect.Effect<A, E, R>): Exit.Exit<A, E | ER>E>(effect: Effect.Effect<A, E, R>(parameter) effect: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
effect: import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<function (type parameter) A in runSyncExit<A, E>(effect: Effect.Effect<A, E, R>): Exit.Exit<A, E | ER>A, function (type parameter) E in runSyncExit<A, E>(effect: Effect.Effect<A, E, R>): Exit.Exit<A, E | ER>E, function (type parameter) R in <R, ER>(layer: Layer.Layer<R, ER, never>, options?: {
readonly memoMap?: Layer.MemoMap | undefined;
} | undefined): ManagedRuntime<R, ER>
R>): import ExitExit.type Exit.Exit = /*unresolved*/ anyExit<function (type parameter) A in runSyncExit<A, E>(effect: Effect.Effect<A, E, R>): Exit.Exit<A, E | ER>A, function (type parameter) E in runSyncExit<A, E>(effect: Effect.Effect<A, E, R>): Exit.Exit<A, E | ER>E | function (type parameter) ER in <R, ER>(layer: Layer.Layer<R, ER, never>, options?: {
readonly memoMap?: Layer.MemoMap | undefined;
} | undefined): ManagedRuntime<R, ER>
ER> {
return const self: ManagedRuntime<R, ER>const self: {
memoMap: Layer.MemoMap;
contextEffect: Effect.Effect<Context.Context<R>, ER>;
context: () => Promise<Context.Context<R>>;
scope: Scope.Closeable;
cachedContext: Context.Context<R> | undefined;
runFork: <A, E>(self: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Fiber.Fiber<A, E | ER>;
runSyncExit: <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, ER | E>;
runSync: <A, E>(effect: Effect.Effect<A, E, R>) => A;
runCallback: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & { readonly onExit: (exit: Exit.Exit<A, E | ER>) => void } | undefined) => (interruptor?: number | undefined) => void;
runPromise: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<A>;
runPromiseExit: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<Exit.Exit<A, ER | E>>;
dispose: () => Promise<void>;
disposeEffect: Effect.Effect<void, never, never>;
}
self.ManagedRuntime<in R, out ER>.cachedContext: Context.Context<R> | undefinedcachedContext === var undefinedundefined ?
import EffectEffect.runSyncExit(function provide<R, ER, A, E>(
managed: ManagedRuntime<R, ER>,
effect: Effect.Effect<A, E, R>
): Effect.Effect<A, E | ER>
provide(const self: ManagedRuntime<R, ER>const self: {
memoMap: Layer.MemoMap;
contextEffect: Effect.Effect<Context.Context<R>, ER>;
context: () => Promise<Context.Context<R>>;
scope: Scope.Closeable;
cachedContext: Context.Context<R> | undefined;
runFork: <A, E>(self: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Fiber.Fiber<A, E | ER>;
runSyncExit: <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, ER | E>;
runSync: <A, E>(effect: Effect.Effect<A, E, R>) => A;
runCallback: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & { readonly onExit: (exit: Exit.Exit<A, E | ER>) => void } | undefined) => (interruptor?: number | undefined) => void;
runPromise: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<A>;
runPromiseExit: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<Exit.Exit<A, ER | E>>;
dispose: () => Promise<void>;
disposeEffect: Effect.Effect<void, never, never>;
}
self, effect: Effect.Effect<A, E, R>(parameter) effect: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
effect)) :
import EffectEffect.runSyncExitWith(const self: ManagedRuntime<R, ER>const self: {
memoMap: Layer.MemoMap;
contextEffect: Effect.Effect<Context.Context<R>, ER>;
context: () => Promise<Context.Context<R>>;
scope: Scope.Closeable;
cachedContext: Context.Context<R> | undefined;
runFork: <A, E>(self: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Fiber.Fiber<A, E | ER>;
runSyncExit: <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, ER | E>;
runSync: <A, E>(effect: Effect.Effect<A, E, R>) => A;
runCallback: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & { readonly onExit: (exit: Exit.Exit<A, E | ER>) => void } | undefined) => (interruptor?: number | undefined) => void;
runPromise: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<A>;
runPromiseExit: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<Exit.Exit<A, ER | E>>;
dispose: () => Promise<void>;
disposeEffect: Effect.Effect<void, never, never>;
}
self.ManagedRuntime<in R, out ER>.cachedContext: Context.Context<R> | undefined(property) ManagedRuntime<in R, out ER>.cachedContext: {
mapUnsafe: ReadonlyMap<string, any>;
mutable: boolean;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
cachedContext)(effect: Effect.Effect<A, E, R>(parameter) effect: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
effect)
},
ManagedRuntime<R, ER>.runSync: <A, E>(effect: Effect.Effect<A, E, R>) => AExecutes the effect synchronously throwing in case of errors or async boundaries.
When to use
Use when invoking this effectful method at the edges of your
program.
runSync<function (type parameter) A in runSync<A, E>(effect: Effect.Effect<A, E, R>): AA, function (type parameter) E in runSync<A, E>(effect: Effect.Effect<A, E, R>): AE>(effect: Effect.Effect<A, E, R>(parameter) effect: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
effect: import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<function (type parameter) A in runSync<A, E>(effect: Effect.Effect<A, E, R>): AA, function (type parameter) E in runSync<A, E>(effect: Effect.Effect<A, E, R>): AE, function (type parameter) R in <R, ER>(layer: Layer.Layer<R, ER, never>, options?: {
readonly memoMap?: Layer.MemoMap | undefined;
} | undefined): ManagedRuntime<R, ER>
R>): function (type parameter) A in runSync<A, E>(effect: Effect.Effect<A, E, R>): AA {
return const self: ManagedRuntime<R, ER>const self: {
memoMap: Layer.MemoMap;
contextEffect: Effect.Effect<Context.Context<R>, ER>;
context: () => Promise<Context.Context<R>>;
scope: Scope.Closeable;
cachedContext: Context.Context<R> | undefined;
runFork: <A, E>(self: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Fiber.Fiber<A, E | ER>;
runSyncExit: <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, ER | E>;
runSync: <A, E>(effect: Effect.Effect<A, E, R>) => A;
runCallback: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & { readonly onExit: (exit: Exit.Exit<A, E | ER>) => void } | undefined) => (interruptor?: number | undefined) => void;
runPromise: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<A>;
runPromiseExit: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<Exit.Exit<A, ER | E>>;
dispose: () => Promise<void>;
disposeEffect: Effect.Effect<void, never, never>;
}
self.ManagedRuntime<in R, out ER>.cachedContext: Context.Context<R> | undefinedcachedContext === var undefinedundefined ?
import EffectEffect.runSync(function provide<R, ER, A, E>(
managed: ManagedRuntime<R, ER>,
effect: Effect.Effect<A, E, R>
): Effect.Effect<A, E | ER>
provide(const self: ManagedRuntime<R, ER>const self: {
memoMap: Layer.MemoMap;
contextEffect: Effect.Effect<Context.Context<R>, ER>;
context: () => Promise<Context.Context<R>>;
scope: Scope.Closeable;
cachedContext: Context.Context<R> | undefined;
runFork: <A, E>(self: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Fiber.Fiber<A, E | ER>;
runSyncExit: <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, ER | E>;
runSync: <A, E>(effect: Effect.Effect<A, E, R>) => A;
runCallback: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & { readonly onExit: (exit: Exit.Exit<A, E | ER>) => void } | undefined) => (interruptor?: number | undefined) => void;
runPromise: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<A>;
runPromiseExit: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<Exit.Exit<A, ER | E>>;
dispose: () => Promise<void>;
disposeEffect: Effect.Effect<void, never, never>;
}
self, effect: Effect.Effect<A, E, R>(parameter) effect: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
effect)) :
import EffectEffect.runSyncWith(const self: ManagedRuntime<R, ER>const self: {
memoMap: Layer.MemoMap;
contextEffect: Effect.Effect<Context.Context<R>, ER>;
context: () => Promise<Context.Context<R>>;
scope: Scope.Closeable;
cachedContext: Context.Context<R> | undefined;
runFork: <A, E>(self: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Fiber.Fiber<A, E | ER>;
runSyncExit: <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, ER | E>;
runSync: <A, E>(effect: Effect.Effect<A, E, R>) => A;
runCallback: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & { readonly onExit: (exit: Exit.Exit<A, E | ER>) => void } | undefined) => (interruptor?: number | undefined) => void;
runPromise: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<A>;
runPromiseExit: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<Exit.Exit<A, ER | E>>;
dispose: () => Promise<void>;
disposeEffect: Effect.Effect<void, never, never>;
}
self.ManagedRuntime<in R, out ER>.cachedContext: Context.Context<R> | undefined(property) ManagedRuntime<in R, out ER>.cachedContext: {
mapUnsafe: ReadonlyMap<string, any>;
mutable: boolean;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
cachedContext)(effect: Effect.Effect<A, E, R>(parameter) effect: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
effect)
},
ManagedRuntime<R, ER>.runPromiseExit: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<Exit.Exit<A, E | ER>>Runs the Effect, returning a JavaScript Promise that will be resolved
with the Exit state of the effect once the effect has been executed.
When to use
Use when invoking this effectful method at the edges of your
program.
runPromiseExit<function (type parameter) A in runPromiseExit<A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions): Promise<Exit.Exit<A, E | ER>>A, function (type parameter) E in runPromiseExit<A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions): Promise<Exit.Exit<A, E | ER>>E>(effect: Effect.Effect<A, E, R>(parameter) effect: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
effect: import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<function (type parameter) A in runPromiseExit<A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions): Promise<Exit.Exit<A, E | ER>>A, function (type parameter) E in runPromiseExit<A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions): Promise<Exit.Exit<A, E | ER>>E, function (type parameter) R in <R, ER>(layer: Layer.Layer<R, ER, never>, options?: {
readonly memoMap?: Layer.MemoMap | undefined;
} | undefined): ManagedRuntime<R, ER>
R>, options: Effect.RunOptionsoptions?: import EffectEffect.type Effect.RunOptions = /*unresolved*/ anyRunOptions): interface Promise<T>Represents the completion of an asynchronous operation
Promise<import ExitExit.type Exit.Exit = /*unresolved*/ anyExit<function (type parameter) A in runPromiseExit<A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions): Promise<Exit.Exit<A, E | ER>>A, function (type parameter) E in runPromiseExit<A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions): Promise<Exit.Exit<A, E | ER>>E | function (type parameter) ER in <R, ER>(layer: Layer.Layer<R, ER, never>, options?: {
readonly memoMap?: Layer.MemoMap | undefined;
} | undefined): ManagedRuntime<R, ER>
ER>> {
return const self: ManagedRuntime<R, ER>const self: {
memoMap: Layer.MemoMap;
contextEffect: Effect.Effect<Context.Context<R>, ER>;
context: () => Promise<Context.Context<R>>;
scope: Scope.Closeable;
cachedContext: Context.Context<R> | undefined;
runFork: <A, E>(self: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Fiber.Fiber<A, E | ER>;
runSyncExit: <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, ER | E>;
runSync: <A, E>(effect: Effect.Effect<A, E, R>) => A;
runCallback: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & { readonly onExit: (exit: Exit.Exit<A, E | ER>) => void } | undefined) => (interruptor?: number | undefined) => void;
runPromise: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<A>;
runPromiseExit: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<Exit.Exit<A, ER | E>>;
dispose: () => Promise<void>;
disposeEffect: Effect.Effect<void, never, never>;
}
self.ManagedRuntime<in R, out ER>.cachedContext: Context.Context<R> | undefinedcachedContext === var undefinedundefined ?
import EffectEffect.runPromiseExit(function provide<R, ER, A, E>(
managed: ManagedRuntime<R, ER>,
effect: Effect.Effect<A, E, R>
): Effect.Effect<A, E | ER>
provide(const self: ManagedRuntime<R, ER>const self: {
memoMap: Layer.MemoMap;
contextEffect: Effect.Effect<Context.Context<R>, ER>;
context: () => Promise<Context.Context<R>>;
scope: Scope.Closeable;
cachedContext: Context.Context<R> | undefined;
runFork: <A, E>(self: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Fiber.Fiber<A, E | ER>;
runSyncExit: <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, ER | E>;
runSync: <A, E>(effect: Effect.Effect<A, E, R>) => A;
runCallback: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & { readonly onExit: (exit: Exit.Exit<A, E | ER>) => void } | undefined) => (interruptor?: number | undefined) => void;
runPromise: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<A>;
runPromiseExit: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<Exit.Exit<A, ER | E>>;
dispose: () => Promise<void>;
disposeEffect: Effect.Effect<void, never, never>;
}
self, effect: Effect.Effect<A, E, R>(parameter) effect: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
effect), const mergeRunOptions: <
O extends Effect.RunOptions
>(
options?: O
) => O
mergeRunOptions(options: Effect.RunOptionsoptions)) :
import EffectEffect.runPromiseExitWith(const self: ManagedRuntime<R, ER>const self: {
memoMap: Layer.MemoMap;
contextEffect: Effect.Effect<Context.Context<R>, ER>;
context: () => Promise<Context.Context<R>>;
scope: Scope.Closeable;
cachedContext: Context.Context<R> | undefined;
runFork: <A, E>(self: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Fiber.Fiber<A, E | ER>;
runSyncExit: <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, ER | E>;
runSync: <A, E>(effect: Effect.Effect<A, E, R>) => A;
runCallback: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & { readonly onExit: (exit: Exit.Exit<A, E | ER>) => void } | undefined) => (interruptor?: number | undefined) => void;
runPromise: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<A>;
runPromiseExit: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<Exit.Exit<A, ER | E>>;
dispose: () => Promise<void>;
disposeEffect: Effect.Effect<void, never, never>;
}
self.ManagedRuntime<in R, out ER>.cachedContext: Context.Context<R> | undefined(property) ManagedRuntime<in R, out ER>.cachedContext: {
mapUnsafe: ReadonlyMap<string, any>;
mutable: boolean;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
cachedContext)(effect: Effect.Effect<A, E, R>(parameter) effect: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
effect, const mergeRunOptions: <
O extends Effect.RunOptions
>(
options?: O
) => O
mergeRunOptions(options: Effect.RunOptionsoptions))
},
ManagedRuntime<R, ER>.runPromise: <A, E>(effect: Effect.Effect<A, E, R>, options?: { readonly signal?: AbortSignal | undefined }) => Promise<A>Runs the Effect, returning a JavaScript Promise that will be resolved
with the value of the effect once the effect has been executed, or will be
rejected with the first error or exception throw by the effect.
When to use
Use when invoking this effectful method at the edges of your
program.
runPromise<function (type parameter) A in runPromise<A, E>(effect: Effect.Effect<A, E, R>, options?: {
readonly signal?: AbortSignal | undefined;
}): Promise<A>
A, function (type parameter) E in runPromise<A, E>(effect: Effect.Effect<A, E, R>, options?: {
readonly signal?: AbortSignal | undefined;
}): Promise<A>
E>(effect: Effect.Effect<A, E, R>(parameter) effect: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
effect: import EffectEffect.type Effect.Effect = /*unresolved*/ anyEffect<function (type parameter) A in runPromise<A, E>(effect: Effect.Effect<A, E, R>, options?: {
readonly signal?: AbortSignal | undefined;
}): Promise<A>
A, function (type parameter) E in runPromise<A, E>(effect: Effect.Effect<A, E, R>, options?: {
readonly signal?: AbortSignal | undefined;
}): Promise<A>
E, function (type parameter) R in <R, ER>(layer: Layer.Layer<R, ER, never>, options?: {
readonly memoMap?: Layer.MemoMap | undefined;
} | undefined): ManagedRuntime<R, ER>
R>, options: | {
readonly signal?: AbortSignal | undefined
}
| undefined
options?: {
readonly signal?: AbortSignal | undefinedsignal?: AbortSignal | undefined
}): interface Promise<T>Represents the completion of an asynchronous operation
Promise<function (type parameter) A in runPromise<A, E>(effect: Effect.Effect<A, E, R>, options?: {
readonly signal?: AbortSignal | undefined;
}): Promise<A>
A> {
return const self: ManagedRuntime<R, ER>const self: {
memoMap: Layer.MemoMap;
contextEffect: Effect.Effect<Context.Context<R>, ER>;
context: () => Promise<Context.Context<R>>;
scope: Scope.Closeable;
cachedContext: Context.Context<R> | undefined;
runFork: <A, E>(self: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Fiber.Fiber<A, E | ER>;
runSyncExit: <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, ER | E>;
runSync: <A, E>(effect: Effect.Effect<A, E, R>) => A;
runCallback: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & { readonly onExit: (exit: Exit.Exit<A, E | ER>) => void } | undefined) => (interruptor?: number | undefined) => void;
runPromise: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<A>;
runPromiseExit: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<Exit.Exit<A, ER | E>>;
dispose: () => Promise<void>;
disposeEffect: Effect.Effect<void, never, never>;
}
self.ManagedRuntime<in R, out ER>.cachedContext: Context.Context<R> | undefinedcachedContext === var undefinedundefined ?
import EffectEffect.runPromise(function provide<R, ER, A, E>(
managed: ManagedRuntime<R, ER>,
effect: Effect.Effect<A, E, R>
): Effect.Effect<A, E | ER>
provide(const self: ManagedRuntime<R, ER>const self: {
memoMap: Layer.MemoMap;
contextEffect: Effect.Effect<Context.Context<R>, ER>;
context: () => Promise<Context.Context<R>>;
scope: Scope.Closeable;
cachedContext: Context.Context<R> | undefined;
runFork: <A, E>(self: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Fiber.Fiber<A, E | ER>;
runSyncExit: <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, ER | E>;
runSync: <A, E>(effect: Effect.Effect<A, E, R>) => A;
runCallback: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & { readonly onExit: (exit: Exit.Exit<A, E | ER>) => void } | undefined) => (interruptor?: number | undefined) => void;
runPromise: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<A>;
runPromiseExit: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<Exit.Exit<A, ER | E>>;
dispose: () => Promise<void>;
disposeEffect: Effect.Effect<void, never, never>;
}
self, effect: Effect.Effect<A, E, R>(parameter) effect: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
effect), const mergeRunOptions: <
O extends Effect.RunOptions
>(
options?: O
) => O
mergeRunOptions(options: | {
readonly signal?: AbortSignal | undefined
}
| undefined
options)) :
import EffectEffect.runPromiseWith(const self: ManagedRuntime<R, ER>const self: {
memoMap: Layer.MemoMap;
contextEffect: Effect.Effect<Context.Context<R>, ER>;
context: () => Promise<Context.Context<R>>;
scope: Scope.Closeable;
cachedContext: Context.Context<R> | undefined;
runFork: <A, E>(self: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Fiber.Fiber<A, E | ER>;
runSyncExit: <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, ER | E>;
runSync: <A, E>(effect: Effect.Effect<A, E, R>) => A;
runCallback: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & { readonly onExit: (exit: Exit.Exit<A, E | ER>) => void } | undefined) => (interruptor?: number | undefined) => void;
runPromise: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<A>;
runPromiseExit: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<Exit.Exit<A, ER | E>>;
dispose: () => Promise<void>;
disposeEffect: Effect.Effect<void, never, never>;
}
self.ManagedRuntime<in R, out ER>.cachedContext: Context.Context<R> | undefined(property) ManagedRuntime<in R, out ER>.cachedContext: {
mapUnsafe: ReadonlyMap<string, any>;
mutable: boolean;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
cachedContext)(effect: Effect.Effect<A, E, R>(parameter) effect: {
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
effect, const mergeRunOptions: <
O extends Effect.RunOptions
>(
options?: O
) => O
mergeRunOptions(options: | {
readonly signal?: AbortSignal | undefined
}
| undefined
options))
}
}
return const self: ManagedRuntime<R, ER>const self: {
memoMap: Layer.MemoMap;
contextEffect: Effect.Effect<Context.Context<R>, ER>;
context: () => Promise<Context.Context<R>>;
scope: Scope.Closeable;
cachedContext: Context.Context<R> | undefined;
runFork: <A, E>(self: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Fiber.Fiber<A, E | ER>;
runSyncExit: <A, E>(effect: Effect.Effect<A, E, R>) => Exit.Exit<A, ER | E>;
runSync: <A, E>(effect: Effect.Effect<A, E, R>) => A;
runCallback: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions & { readonly onExit: (exit: Exit.Exit<A, E | ER>) => void } | undefined) => (interruptor?: number | undefined) => void;
runPromise: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<A>;
runPromiseExit: <A, E>(effect: Effect.Effect<A, E, R>, options?: Effect.RunOptions) => Promise<Exit.Exit<A, ER | E>>;
dispose: () => Promise<void>;
disposeEffect: Effect.Effect<void, never, never>;
}
self
}