<A extends Any>(result: Result<A>): (
self: Entry<A>
) => Effect.Effect<void>
<A extends Any>(self: Entry<A>, result: Result<A>): Effect.Effect<void>Completes a request entry with the provided result.
When to use
Use when you need to finish a Request.Entry with a prebuilt final Exit
result.
export const 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>
}
Completes a request entry with the provided result.
When to use
Use when you need to finish a Request.Entry with a prebuilt final Exit
result.
complete: {
<function (type parameter) A in <A extends Any>(result: Result<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>(result: Result<A>result: type Result<
T extends Request<any, any, any>
> = T extends Request<infer A, infer E, infer _R>
? Exit.Exit<A, E>
: never
A utility type to extract the result type from a Request.
Example (Extracting a request result type)
import type { Request } from "effect"
interface GetUser extends Request.Request<string, Error> {
readonly _tag: "GetUser"
readonly id: number
}
// Extract the result type from a Request using the utility
type UserResult = Request.Result<GetUser> // Exit.Exit<string, Error>
Result<function (type parameter) A in <A extends Any>(result: Result<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>(result: Result<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>, result: Result<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>, result: Result<A>): Effect.Effect<void>A>, result: Result<A>result: type Result<
T extends Request<any, any, any>
> = T extends Request<infer A, infer E, infer _R>
? Exit.Exit<A, E>
: never
A utility type to extract the result type from a Request.
Example (Extracting a request result type)
import type { Request } from "effect"
interface GetUser extends Request.Request<string, Error> {
readonly _tag: "GetUser"
readonly id: number
}
// Extract the result type from a Request using the utility
type UserResult = Request.Result<GetUser> // Exit.Exit<string, Error>
Result<function (type parameter) A in <A extends Any>(self: Entry<A>, result: Result<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>, result: Result<A>) => Effect.Effect<void>>(arity: 2, body: <A extends Any>(self: Entry<A>, result: Result<A>) => Effect.Effect<void>): ((...args: Array<any>) => any) & (<A extends Any>(self: Entry<A>, result: Result<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>, result: Result<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>, result: Result<A>): Effect.Effect<void>A>, result: Result<A>result: type Result<
T extends Request<any, any, any>
> = T extends Request<infer A, infer E, infer _R>
? Exit.Exit<A, E>
: never
A utility type to extract the result type from a Request.
Example (Extracting a request result type)
import type { Request } from "effect"
interface GetUser extends Request.Request<string, Error> {
readonly _tag: "GetUser"
readonly id: number
}
// Extract the result type from a Request using the utility
type UserResult = Request.Result<GetUser> // Exit.Exit<string, Error>
Result<function (type parameter) A in <A extends Any>(self: Entry<A>, result: Result<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> =>
import internalEffectinternalEffect.const sync: <A>(
thunk: LazyArg<A>
) => Effect.Effect<A>
sync(() => 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.Entry<A>.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>): voidcompleteUnsafe(result: Result<A>result))
)