<A extends Any>(cause: Cause.Cause<Error<A>>): (
self: Entry<A>
) => Effect.Effect<void>
<A extends Any>(
self: Entry<A>,
cause: Cause.Cause<Error<A>>
): Effect.Effect<void>Completes a request entry with a failure Cause.
When to use
Use when you need a RequestResolver to complete an entry with structured
cause information rather than only the request's typed error value.
export const const failCause: {
<A extends Any>(cause: Cause.Cause<Error<A>>): (
self: Entry<A>
) => Effect.Effect<void>
<A extends Any>(
self: Entry<A>,
cause: Cause.Cause<Error<A>>
): Effect.Effect<void>
}
Completes a request entry with a failure Cause.
When to use
Use when you need a RequestResolver to complete an entry with structured
cause information rather than only the request's typed error value.
failCause: {
<function (type parameter) A in <A extends Any>(cause: Cause.Cause<Error<A>>): (self: Entry<A>) => Effect.Effect<void>A extends type Any = Request<any, any, any>Alias for any Request, regardless of its success, error, or service
requirements.
When to use
Use as a generic constraint for APIs that accept any request while preserving
each concrete request's success, error, and service types.
Any>(cause: Cause.Cause<Error<A>>(parameter) cause: {
reasons: ReadonlyArray<Reason<E>>;
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;
}
cause: import CauseCause.interface Cause<out E>A structured representation of how an Effect failed.
When to use
Use to preserve the full structured failure information for an effect instead
of collapsing it to a single error value.
Details
Access the individual failure entries through the reasons array, then
narrow each entry with
isFailReason
,
isDieReason
, or
- Use
hasFails
/
hasDies
/
hasInterrupts
to test
for the presence of specific reason kinds without iterating.
- Use
findError
/
findDefect
to extract the first value
of a given kind.
- Use
combine
to merge two causes.
Cause implements Equal — two causes with the same reasons (by value)
compare as equal.
Example (Creating and inspecting a cause)
import { Cause } from "effect"
const cause = Cause.fail("Something went wrong")
console.log(cause.reasons.length) // 1
console.log(Cause.isFailReason(cause.reasons[0])) // true
Companion namespace for the Cause interface.
Cause<type Error<
T extends Request<any, any, any>
> = [T] extends [
Request<infer _A, infer _E, infer _R>
]
? _E
: never
A utility type to extract the error type from a Request.
Example (Extracting a request error type)
import type { Request } from "effect"
interface GetUser extends Request.Request<string, Error> {
readonly id: number
}
// Extract the error type from a Request using the utility
type UserError = Request.Error<GetUser> // Error
Error<function (type parameter) A in <A extends Any>(cause: Cause.Cause<Error<A>>): (self: Entry<A>) => Effect.Effect<void>A>>): (self: Entry<A>(parameter) self: {
request: R;
context: Context.Context<[R] extends [Request<infer _A, infer _E, infer _R>] ? _R : never>;
uninterruptible: boolean;
completeUnsafe: (exit: Exit.Exit<[A] extends [Request<infer _A, infer _E, infer _R>] ? _A : never, [A] extends [Request<infer _A, infer _E, infer _R>] ? _E : never>) => void;
}
self: interface Entry<out R>A pending request handed to a RequestResolver.
Details
An entry contains the original request, the fiber context needed to run it,
an uninterruptible flag used by batching and caching internals, and the
completeUnsafe callback used by resolvers to supply the final Exit.
Entry<function (type parameter) A in <A extends Any>(cause: Cause.Cause<Error<A>>): (self: Entry<A>) => Effect.Effect<void>A>) => import EffectEffect.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) A in <A extends Any>(self: Entry<A>, cause: Cause.Cause<Error<A>>): Effect.Effect<void>A extends type Any = Request<any, any, any>Alias for any Request, regardless of its success, error, or service
requirements.
When to use
Use as a generic constraint for APIs that accept any request while preserving
each concrete request's success, error, and service types.
Any>(self: Entry<A>(parameter) self: {
request: R;
context: Context.Context<[R] extends [Request<infer _A, infer _E, infer _R>] ? _R : never>;
uninterruptible: boolean;
completeUnsafe: (exit: Exit.Exit<[A] extends [Request<infer _A, infer _E, infer _R>] ? _A : never, [A] extends [Request<infer _A, infer _E, infer _R>] ? _E : never>) => void;
}
self: interface Entry<out R>A pending request handed to a RequestResolver.
Details
An entry contains the original request, the fiber context needed to run it,
an uninterruptible flag used by batching and caching internals, and the
completeUnsafe callback used by resolvers to supply the final Exit.
Entry<function (type parameter) A in <A extends Any>(self: Entry<A>, cause: Cause.Cause<Error<A>>): Effect.Effect<void>A>, cause: Cause.Cause<Error<A>>(parameter) cause: {
reasons: ReadonlyArray<Reason<E>>;
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;
}
cause: import CauseCause.interface Cause<out E>A structured representation of how an Effect failed.
When to use
Use to preserve the full structured failure information for an effect instead
of collapsing it to a single error value.
Details
Access the individual failure entries through the reasons array, then
narrow each entry with
isFailReason
,
isDieReason
, or
- Use
hasFails
/
hasDies
/
hasInterrupts
to test
for the presence of specific reason kinds without iterating.
- Use
findError
/
findDefect
to extract the first value
of a given kind.
- Use
combine
to merge two causes.
Cause implements Equal — two causes with the same reasons (by value)
compare as equal.
Example (Creating and inspecting a cause)
import { Cause } from "effect"
const cause = Cause.fail("Something went wrong")
console.log(cause.reasons.length) // 1
console.log(Cause.isFailReason(cause.reasons[0])) // true
Companion namespace for the Cause interface.
Cause<type Error<
T extends Request<any, any, any>
> = [T] extends [
Request<infer _A, infer _E, infer _R>
]
? _E
: never
A utility type to extract the error type from a Request.
Example (Extracting a request error type)
import type { Request } from "effect"
interface GetUser extends Request.Request<string, Error> {
readonly id: number
}
// Extract the error type from a Request using the utility
type UserError = Request.Error<GetUser> // Error
Error<function (type parameter) A in <A extends Any>(self: Entry<A>, cause: Cause.Cause<Error<A>>): Effect.Effect<void>A>>): import EffectEffect.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>
} = dual<(...args: Array<any>) => any, <A extends Any>(self: Entry<A>, cause: Cause.Cause<Error<A>>) => Effect.Effect<void>>(arity: 2, body: <A extends Any>(self: Entry<A>, cause: Cause.Cause<Error<A>>) => Effect.Effect<void>): ((...args: Array<any>) => any) & (<A extends Any>(self: Entry<A>, cause: Cause.Cause<Error<A>>) => Effect.Effect<void>) (+1 overload)Creates a function that can be called in data-first style or data-last
(pipe-friendly) style.
When to use
Use to expose one implementation through both direct and pipe-friendly
call styles.
Details
Pass either the arity of the uncurried function or a predicate that decides
whether the current call is data-first. Arity is the common case. Use a
predicate when optional arguments make arity ambiguous.
Example (Selecting data-first or data-last style by arity)
import { Function, pipe } from "effect"
const sum = Function.dual<
(that: number) => (self: number) => number,
(self: number, that: number) => number
>(2, (self, that) => self + that)
console.log(sum(2, 3)) // 5
console.log(pipe(2, sum(3))) // 5
Example (Defining overloads with call signatures)
import { Function, pipe } from "effect"
const sum: {
(that: number): (self: number) => number
(self: number, that: number): number
} = Function.dual(2, (self: number, that: number): number => self + that)
console.log(sum(2, 3)) // 5
console.log(pipe(2, sum(3))) // 5
Example (Selecting data-first or data-last style with a predicate)
import { Function, pipe } from "effect"
const sum = Function.dual<
(that: number) => (self: number) => number,
(self: number, that: number) => number
>(
(args) => args.length === 2,
(self, that) => self + that
)
console.log(sum(2, 3)) // 5
console.log(pipe(2, sum(3))) // 5
dual(
2,
<function (type parameter) A in <A extends Any>(self: Entry<A>, cause: Cause.Cause<Error<A>>): Effect.Effect<void>A extends type Any = Request<any, any, any>Alias for any Request, regardless of its success, error, or service
requirements.
When to use
Use as a generic constraint for APIs that accept any request while preserving
each concrete request's success, error, and service types.
Any>(self: Entry<A>(parameter) self: {
request: R;
context: Context.Context<[R] extends [Request<infer _A, infer _E, infer _R>] ? _R : never>;
uninterruptible: boolean;
completeUnsafe: (exit: Exit.Exit<[A] extends [Request<infer _A, infer _E, infer _R>] ? _A : never, [A] extends [Request<infer _A, infer _E, infer _R>] ? _E : never>) => void;
}
self: interface Entry<out R>A pending request handed to a RequestResolver.
Details
An entry contains the original request, the fiber context needed to run it,
an uninterruptible flag used by batching and caching internals, and the
completeUnsafe callback used by resolvers to supply the final Exit.
Entry<function (type parameter) A in <A extends Any>(self: Entry<A>, cause: Cause.Cause<Error<A>>): Effect.Effect<void>A>, cause: Cause.Cause<Error<A>>(parameter) cause: {
reasons: ReadonlyArray<Reason<E>>;
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;
}
cause: import CauseCause.interface Cause<out E>A structured representation of how an Effect failed.
When to use
Use to preserve the full structured failure information for an effect instead
of collapsing it to a single error value.
Details
Access the individual failure entries through the reasons array, then
narrow each entry with
isFailReason
,
isDieReason
, or
- Use
hasFails
/
hasDies
/
hasInterrupts
to test
for the presence of specific reason kinds without iterating.
- Use
findError
/
findDefect
to extract the first value
of a given kind.
- Use
combine
to merge two causes.
Cause implements Equal — two causes with the same reasons (by value)
compare as equal.
Example (Creating and inspecting a cause)
import { Cause } from "effect"
const cause = Cause.fail("Something went wrong")
console.log(cause.reasons.length) // 1
console.log(Cause.isFailReason(cause.reasons[0])) // true
Companion namespace for the Cause interface.
Cause<type Error<
T extends Request<any, any, any>
> = [T] extends [
Request<infer _A, infer _E, infer _R>
]
? _E
: never
A utility type to extract the error type from a Request.
Example (Extracting a request error type)
import type { Request } from "effect"
interface GetUser extends Request.Request<string, Error> {
readonly id: number
}
// Extract the error type from a Request using the utility
type UserError = Request.Error<GetUser> // Error
Error<function (type parameter) A in <A extends Any>(self: Entry<A>, cause: Cause.Cause<Error<A>>): Effect.Effect<void>A>>): import EffectEffect.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> =>
const complete: {
<A extends Any>(result: Result<A>): (
self: Entry<A>
) => Effect.Effect<void>
<A extends Any>(
self: Entry<A>,
result: Result<A>
): Effect.Effect<void>
}
complete(self: Entry<A>(parameter) self: {
request: R;
context: Context.Context<[R] extends [Request<infer _A, infer _E, infer _R>] ? _R : never>;
uninterruptible: boolean;
completeUnsafe: (exit: Exit.Exit<[A] extends [Request<infer _A, infer _E, infer _R>] ? _A : never, [A] extends [Request<infer _A, infer _E, infer _R>] ? _E : never>) => void;
}
self, import corecore.const exitFailCause: <E>(
cause: Cause.Cause<E>
) => Exit.Exit<never, E>
exitFailCause(cause: Cause.Cause<Error<A>>(parameter) cause: {
reasons: ReadonlyArray<Reason<E>>;
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;
}
cause) as any)
)