<A, E, XE, XR>(
predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>,
f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>
): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>
<A, E, R, XE, XR>(
self: Effect<A, E, R>,
predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>,
f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>
): Effect<A, E | XE, R | XR>Runs the cleanup effect only when the Exit satisfies the provided
predicate.
Example (Observing selected exits)
import { Console, Effect, Exit } from "effect"
const program = Effect.onExitIf(
Effect.succeed(42),
Exit.isSuccess,
(exit) =>
Exit.isSuccess(exit)
? Console.log(`Succeeded with: ${exit.value}`)
: Effect.void
)export const const onExitIf: {
<A, E, XE, XR>(
predicate: Predicate.Predicate<
Exit.Exit<NoInfer<A>, NoInfer<E>>
>,
f: (
exit: Exit.Exit<NoInfer<A>, NoInfer<E>>
) => Effect<void, XE, XR>
): <R>(
self: Effect<A, E, R>
) => Effect<A, E | XE, R | XR>
<A, E, R, XE, XR>(
self: Effect<A, E, R>,
predicate: Predicate.Predicate<
Exit.Exit<NoInfer<A>, NoInfer<E>>
>,
f: (
exit: Exit.Exit<NoInfer<A>, NoInfer<E>>
) => Effect<void, XE, XR>
): Effect<A, E | XE, R | XR>
}
Runs the cleanup effect only when the Exit satisfies the provided
predicate.
Example (Observing selected exits)
import { Console, Effect, Exit } from "effect"
const program = Effect.onExitIf(
Effect.succeed(42),
Exit.isSuccess,
(exit) =>
Exit.isSuccess(exit)
? Console.log(`Succeeded with: ${exit.value}`)
: Effect.void
)
onExitIf: {
<function (type parameter) A in <A, E, XE, XR>(predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>A, function (type parameter) E in <A, E, XE, XR>(predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>E, function (type parameter) XE in <A, E, XE, XR>(predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>XE, function (type parameter) XR in <A, E, XE, XR>(predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>XR>(
predicate: Predicate.Predicate<
Exit.Exit<NoInfer<A>, NoInfer<E>>
>
predicate: import PredicatePredicate.interface Predicate<in A>A function that decides whether a value of type A satisfies a condition.
When to use
Use when you want a reusable boolean check for A, especially when you plan
to combine checks with
and
/
or
or pass a predicate to arrays
and iterables.
Details
A predicate returns true or false and never throws by itself. It does not
narrow types unless you use Refinement.
Example (Defining a predicate)
import { Predicate } from "effect"
const isPositive: Predicate.Predicate<number> = (n) => n > 0
console.log(isPositive(1))
Type-level utilities for working with
Predicate
types.
When to use
Use when you need to extract input types from predicate signatures while
writing generic helpers over predicate types.
Details
These utilities are type-only, create no runtime values, and the namespace is
erased at runtime.
Example (Extracting predicate input)
import { Predicate } from "effect"
type IsString = Predicate.Predicate<string>
type Input = Predicate.Predicate.In<IsString>
Predicate<import ExitExit.type Exit<A, E = never> = Exit.Success<A, E> | Exit.Failure<A, E>Represents the result of an Effect computation.
When to use
Use when you need to synchronously inspect whether an Effect computation
succeeded or failed.
Details
An Exit<A, E> is either Success<A, E> containing a value of type A, or
Failure<A, E> containing a Cause<E> describing why the computation
failed.
Since Exit is also an Effect, you can yield it inside Effect.gen.
Example (Pattern matching on an Exit)
import { Exit } from "effect"
const success: Exit.Exit<number> = Exit.succeed(42)
const failure: Exit.Exit<number, string> = Exit.fail("error")
const result = Exit.match(success, {
onSuccess: (value) => `Got value: ${value}`,
onFailure: (cause) => `Got error: ${cause}`
})
Namespace containing helper types shared by Exit values.
When to use
Use to reference helper types that describe the shared structure of Exit
values.
Exit<type NoInfer<A> = [A][A extends any ? 0 : never]Prevents TypeScript from inferring a type parameter from a specific
position.
When to use
Use when a function parameter must match an inferred type without becoming
an inference source.
Details
The parameter using NoInfer must still match the inferred type.
Example (Controlling inference)
import type { Types } from "effect"
declare function withDefault<T>(value: T, fallback: Types.NoInfer<T>): T
// T is inferred as "a" | "b" from the first argument only
const result = withDefault<"a" | "b">("a", "b")
NoInfer<function (type parameter) A in <A, E, XE, XR>(predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>A>, type NoInfer<A> = [A][A extends any ? 0 : never]Prevents TypeScript from inferring a type parameter from a specific
position.
When to use
Use when a function parameter must match an inferred type without becoming
an inference source.
Details
The parameter using NoInfer must still match the inferred type.
Example (Controlling inference)
import type { Types } from "effect"
declare function withDefault<T>(value: T, fallback: Types.NoInfer<T>): T
// T is inferred as "a" | "b" from the first argument only
const result = withDefault<"a" | "b">("a", "b")
NoInfer<function (type parameter) E in <A, E, XE, XR>(predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>E>>>,
f: (
exit: Exit.Exit<NoInfer<A>, NoInfer<E>>
) => Effect<void, XE, XR>
f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>exit: import ExitExit.type Exit<A, E = never> = Exit.Success<A, E> | Exit.Failure<A, E>Represents the result of an Effect computation.
When to use
Use when you need to synchronously inspect whether an Effect computation
succeeded or failed.
Details
An Exit<A, E> is either Success<A, E> containing a value of type A, or
Failure<A, E> containing a Cause<E> describing why the computation
failed.
Since Exit is also an Effect, you can yield it inside Effect.gen.
Example (Pattern matching on an Exit)
import { Exit } from "effect"
const success: Exit.Exit<number> = Exit.succeed(42)
const failure: Exit.Exit<number, string> = Exit.fail("error")
const result = Exit.match(success, {
onSuccess: (value) => `Got value: ${value}`,
onFailure: (cause) => `Got error: ${cause}`
})
Namespace containing helper types shared by Exit values.
When to use
Use to reference helper types that describe the shared structure of Exit
values.
Exit<type NoInfer<A> = [A][A extends any ? 0 : never]Prevents TypeScript from inferring a type parameter from a specific
position.
When to use
Use when a function parameter must match an inferred type without becoming
an inference source.
Details
The parameter using NoInfer must still match the inferred type.
Example (Controlling inference)
import type { Types } from "effect"
declare function withDefault<T>(value: T, fallback: Types.NoInfer<T>): T
// T is inferred as "a" | "b" from the first argument only
const result = withDefault<"a" | "b">("a", "b")
NoInfer<function (type parameter) A in <A, E, XE, XR>(predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>A>, type NoInfer<A> = [A][A extends any ? 0 : never]Prevents TypeScript from inferring a type parameter from a specific
position.
When to use
Use when a function parameter must match an inferred type without becoming
an inference source.
Details
The parameter using NoInfer must still match the inferred type.
Example (Controlling inference)
import type { Types } from "effect"
declare function withDefault<T>(value: T, fallback: Types.NoInfer<T>): T
// T is inferred as "a" | "b" from the first argument only
const result = withDefault<"a" | "b">("a", "b")
NoInfer<function (type parameter) E in <A, E, XE, XR>(predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>E>>) => interface Effect<out A, out E = never, out R = never>The Effect interface defines a value that lazily describes a workflow or
job. The workflow requires some context R, and may fail with an error of
type E, or succeed with a value of type A.
When to use
Use when you need to represent a lazy, composable workflow that can require
services, fail with a typed error, or succeed with a typed value.
Details
Effect values model resourceful interaction with the outside world,
including synchronous, asynchronous, concurrent, and parallel interaction.
They use a fiber-based concurrency model, with built-in support for
scheduling, fine-grained interruption, structured concurrency, and high
scalability.
To run an Effect value, you need a Runtime, which is a type that is
capable of executing Effect values.
Effect<void, function (type parameter) XE in <A, E, XE, XR>(predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>XE, function (type parameter) XR in <A, E, XE, XR>(predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>XR>
): <function (type parameter) R in <R>(self: Effect<A, E, R>): Effect<A, E | XE, R | XR>R>(self: Effect<A, E, R>(parameter) self: {
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;
}
self: interface Effect<out A, out E = never, out R = never>The Effect interface defines a value that lazily describes a workflow or
job. The workflow requires some context R, and may fail with an error of
type E, or succeed with a value of type A.
When to use
Use when you need to represent a lazy, composable workflow that can require
services, fail with a typed error, or succeed with a typed value.
Details
Effect values model resourceful interaction with the outside world,
including synchronous, asynchronous, concurrent, and parallel interaction.
They use a fiber-based concurrency model, with built-in support for
scheduling, fine-grained interruption, structured concurrency, and high
scalability.
To run an Effect value, you need a Runtime, which is a type that is
capable of executing Effect values.
Effect<function (type parameter) A in <A, E, XE, XR>(predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>A, function (type parameter) E in <A, E, XE, XR>(predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>E, function (type parameter) R in <R>(self: Effect<A, E, R>): Effect<A, E | XE, R | XR>R>) => interface Effect<out A, out E = never, out R = never>The Effect interface defines a value that lazily describes a workflow or
job. The workflow requires some context R, and may fail with an error of
type E, or succeed with a value of type A.
When to use
Use when you need to represent a lazy, composable workflow that can require
services, fail with a typed error, or succeed with a typed value.
Details
Effect values model resourceful interaction with the outside world,
including synchronous, asynchronous, concurrent, and parallel interaction.
They use a fiber-based concurrency model, with built-in support for
scheduling, fine-grained interruption, structured concurrency, and high
scalability.
To run an Effect value, you need a Runtime, which is a type that is
capable of executing Effect values.
Effect<function (type parameter) A in <A, E, XE, XR>(predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>A, function (type parameter) E in <A, E, XE, XR>(predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>E | function (type parameter) XE in <A, E, XE, XR>(predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>XE, function (type parameter) R in <R>(self: Effect<A, E, R>): Effect<A, E | XE, R | XR>R | function (type parameter) XR in <A, E, XE, XR>(predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): <R>(self: Effect<A, E, R>) => Effect<A, E | XE, R | XR>XR>
<function (type parameter) A in <A, E, R, XE, XR>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>A, function (type parameter) E in <A, E, R, XE, XR>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>E, function (type parameter) R in <A, E, R, XE, XR>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>R, function (type parameter) XE in <A, E, R, XE, XR>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>XE, function (type parameter) XR in <A, E, R, XE, XR>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>XR>(
self: Effect<A, E, R>(parameter) self: {
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;
}
self: interface Effect<out A, out E = never, out R = never>The Effect interface defines a value that lazily describes a workflow or
job. The workflow requires some context R, and may fail with an error of
type E, or succeed with a value of type A.
When to use
Use when you need to represent a lazy, composable workflow that can require
services, fail with a typed error, or succeed with a typed value.
Details
Effect values model resourceful interaction with the outside world,
including synchronous, asynchronous, concurrent, and parallel interaction.
They use a fiber-based concurrency model, with built-in support for
scheduling, fine-grained interruption, structured concurrency, and high
scalability.
To run an Effect value, you need a Runtime, which is a type that is
capable of executing Effect values.
Effect<function (type parameter) A in <A, E, R, XE, XR>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>A, function (type parameter) E in <A, E, R, XE, XR>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>E, function (type parameter) R in <A, E, R, XE, XR>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>R>,
predicate: Predicate.Predicate<
Exit.Exit<NoInfer<A>, NoInfer<E>>
>
predicate: import PredicatePredicate.interface Predicate<in A>A function that decides whether a value of type A satisfies a condition.
When to use
Use when you want a reusable boolean check for A, especially when you plan
to combine checks with
and
/
or
or pass a predicate to arrays
and iterables.
Details
A predicate returns true or false and never throws by itself. It does not
narrow types unless you use Refinement.
Example (Defining a predicate)
import { Predicate } from "effect"
const isPositive: Predicate.Predicate<number> = (n) => n > 0
console.log(isPositive(1))
Type-level utilities for working with
Predicate
types.
When to use
Use when you need to extract input types from predicate signatures while
writing generic helpers over predicate types.
Details
These utilities are type-only, create no runtime values, and the namespace is
erased at runtime.
Example (Extracting predicate input)
import { Predicate } from "effect"
type IsString = Predicate.Predicate<string>
type Input = Predicate.Predicate.In<IsString>
Predicate<import ExitExit.type Exit<A, E = never> = Exit.Success<A, E> | Exit.Failure<A, E>Represents the result of an Effect computation.
When to use
Use when you need to synchronously inspect whether an Effect computation
succeeded or failed.
Details
An Exit<A, E> is either Success<A, E> containing a value of type A, or
Failure<A, E> containing a Cause<E> describing why the computation
failed.
Since Exit is also an Effect, you can yield it inside Effect.gen.
Example (Pattern matching on an Exit)
import { Exit } from "effect"
const success: Exit.Exit<number> = Exit.succeed(42)
const failure: Exit.Exit<number, string> = Exit.fail("error")
const result = Exit.match(success, {
onSuccess: (value) => `Got value: ${value}`,
onFailure: (cause) => `Got error: ${cause}`
})
Namespace containing helper types shared by Exit values.
When to use
Use to reference helper types that describe the shared structure of Exit
values.
Exit<type NoInfer<A> = [A][A extends any ? 0 : never]Prevents TypeScript from inferring a type parameter from a specific
position.
When to use
Use when a function parameter must match an inferred type without becoming
an inference source.
Details
The parameter using NoInfer must still match the inferred type.
Example (Controlling inference)
import type { Types } from "effect"
declare function withDefault<T>(value: T, fallback: Types.NoInfer<T>): T
// T is inferred as "a" | "b" from the first argument only
const result = withDefault<"a" | "b">("a", "b")
NoInfer<function (type parameter) A in <A, E, R, XE, XR>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>A>, type NoInfer<A> = [A][A extends any ? 0 : never]Prevents TypeScript from inferring a type parameter from a specific
position.
When to use
Use when a function parameter must match an inferred type without becoming
an inference source.
Details
The parameter using NoInfer must still match the inferred type.
Example (Controlling inference)
import type { Types } from "effect"
declare function withDefault<T>(value: T, fallback: Types.NoInfer<T>): T
// T is inferred as "a" | "b" from the first argument only
const result = withDefault<"a" | "b">("a", "b")
NoInfer<function (type parameter) E in <A, E, R, XE, XR>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>E>>>,
f: (
exit: Exit.Exit<NoInfer<A>, NoInfer<E>>
) => Effect<void, XE, XR>
f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>exit: import ExitExit.type Exit<A, E = never> = Exit.Success<A, E> | Exit.Failure<A, E>Represents the result of an Effect computation.
When to use
Use when you need to synchronously inspect whether an Effect computation
succeeded or failed.
Details
An Exit<A, E> is either Success<A, E> containing a value of type A, or
Failure<A, E> containing a Cause<E> describing why the computation
failed.
Since Exit is also an Effect, you can yield it inside Effect.gen.
Example (Pattern matching on an Exit)
import { Exit } from "effect"
const success: Exit.Exit<number> = Exit.succeed(42)
const failure: Exit.Exit<number, string> = Exit.fail("error")
const result = Exit.match(success, {
onSuccess: (value) => `Got value: ${value}`,
onFailure: (cause) => `Got error: ${cause}`
})
Namespace containing helper types shared by Exit values.
When to use
Use to reference helper types that describe the shared structure of Exit
values.
Exit<type NoInfer<A> = [A][A extends any ? 0 : never]Prevents TypeScript from inferring a type parameter from a specific
position.
When to use
Use when a function parameter must match an inferred type without becoming
an inference source.
Details
The parameter using NoInfer must still match the inferred type.
Example (Controlling inference)
import type { Types } from "effect"
declare function withDefault<T>(value: T, fallback: Types.NoInfer<T>): T
// T is inferred as "a" | "b" from the first argument only
const result = withDefault<"a" | "b">("a", "b")
NoInfer<function (type parameter) A in <A, E, R, XE, XR>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>A>, type NoInfer<A> = [A][A extends any ? 0 : never]Prevents TypeScript from inferring a type parameter from a specific
position.
When to use
Use when a function parameter must match an inferred type without becoming
an inference source.
Details
The parameter using NoInfer must still match the inferred type.
Example (Controlling inference)
import type { Types } from "effect"
declare function withDefault<T>(value: T, fallback: Types.NoInfer<T>): T
// T is inferred as "a" | "b" from the first argument only
const result = withDefault<"a" | "b">("a", "b")
NoInfer<function (type parameter) E in <A, E, R, XE, XR>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>E>>) => interface Effect<out A, out E = never, out R = never>The Effect interface defines a value that lazily describes a workflow or
job. The workflow requires some context R, and may fail with an error of
type E, or succeed with a value of type A.
When to use
Use when you need to represent a lazy, composable workflow that can require
services, fail with a typed error, or succeed with a typed value.
Details
Effect values model resourceful interaction with the outside world,
including synchronous, asynchronous, concurrent, and parallel interaction.
They use a fiber-based concurrency model, with built-in support for
scheduling, fine-grained interruption, structured concurrency, and high
scalability.
To run an Effect value, you need a Runtime, which is a type that is
capable of executing Effect values.
Effect<void, function (type parameter) XE in <A, E, R, XE, XR>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>XE, function (type parameter) XR in <A, E, R, XE, XR>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>XR>
): interface Effect<out A, out E = never, out R = never>The Effect interface defines a value that lazily describes a workflow or
job. The workflow requires some context R, and may fail with an error of
type E, or succeed with a value of type A.
When to use
Use when you need to represent a lazy, composable workflow that can require
services, fail with a typed error, or succeed with a typed value.
Details
Effect values model resourceful interaction with the outside world,
including synchronous, asynchronous, concurrent, and parallel interaction.
They use a fiber-based concurrency model, with built-in support for
scheduling, fine-grained interruption, structured concurrency, and high
scalability.
To run an Effect value, you need a Runtime, which is a type that is
capable of executing Effect values.
Effect<function (type parameter) A in <A, E, R, XE, XR>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>A, function (type parameter) E in <A, E, R, XE, XR>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>E | function (type parameter) XE in <A, E, R, XE, XR>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>XE, function (type parameter) R in <A, E, R, XE, XR>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>R | function (type parameter) XR in <A, E, R, XE, XR>(self: Effect<A, E, R>, predicate: Predicate.Predicate<Exit.Exit<NoInfer<A>, NoInfer<E>>>, f: (exit: Exit.Exit<NoInfer<A>, NoInfer<E>>) => Effect<void, XE, XR>): Effect<A, E | XE, R | XR>XR>
} = import internalinternal.const onExitIf: {
<A, E, XE, XR>(
predicate: Predicate.Predicate<
Exit.Exit<NoInfer<A>, NoInfer<E>>
>,
f: (
exit: Exit.Exit<NoInfer<A>, NoInfer<E>>
) => Effect.Effect<void, XE, XR>
): <R>(
self: Effect.Effect<A, E, R>
) => Effect.Effect<A, E | XE, R | XR>
<A, E, R, XE, XR>(
self: Effect.Effect<A, E, R>,
predicate: Predicate.Predicate<
Exit.Exit<NoInfer<A>, NoInfer<E>>
>,
f: (
exit: Exit.Exit<NoInfer<A>, NoInfer<E>>
) => Effect.Effect<void, XE, XR>
): Effect.Effect<A, E | XE, R | XR>
}
onExitIf