<A, B, E, R>(
f: (a: A, i: number) => Effect<B, E, R>,
options?: { readonly concurrency?: Concurrency | undefined }
): (
elements: Iterable<A>
) => Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
<A, B, E, R>(
elements: Iterable<A>,
f: (a: A, i: number) => Effect<B, E, R>,
options?: { readonly concurrency?: Concurrency | undefined }
): Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>Applies an effectful function to each element and partitions failures and successes.
Details
The returned tuple is [excluded, satisfying], where excluded contains
all failures and satisfying contains all successes.
This function runs every effect and never fails. Use concurrency to control
parallelism.
Example (Separating successes and failures)
import { Effect } from "effect"
const program = Effect.partition([0, 1, 2, 3], (n) =>
n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
)
Effect.runPromise(program).then(console.log)
// [ ["0 is even", "2 is even"], [1, 3] ]export const const partition: {
<A, B, E, R>(
f: (a: A, i: number) => Effect<B, E, R>,
options?: {
readonly concurrency?:
| Concurrency
| undefined
}
): (
elements: Iterable<A>
) => Effect<
[excluded: Array<E>, satisfying: Array<B>],
never,
R
>
<A, B, E, R>(
elements: Iterable<A>,
f: (a: A, i: number) => Effect<B, E, R>,
options?: {
readonly concurrency?:
| Concurrency
| undefined
}
): Effect<
[excluded: Array<E>, satisfying: Array<B>],
never,
R
>
}
Applies an effectful function to each element and partitions failures and
successes.
Details
The returned tuple is [excluded, satisfying], where excluded contains
all failures and satisfying contains all successes.
This function runs every effect and never fails. Use concurrency to control
parallelism.
Example (Separating successes and failures)
import { Effect } from "effect"
const program = Effect.partition([0, 1, 2, 3], (n) =>
n % 2 === 0 ? Effect.fail(`${n} is even`) : Effect.succeed(n)
)
Effect.runPromise(program).then(console.log)
// [ ["0 is even", "2 is even"], [1, 3] ]
partition: {
<function (type parameter) A in <A, B, E, R>(f: (a: A, i: number) => Effect<B, E, R>, options?: {
readonly concurrency?: Concurrency | undefined;
}): (elements: Iterable<A>) => Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
A, function (type parameter) B in <A, B, E, R>(f: (a: A, i: number) => Effect<B, E, R>, options?: {
readonly concurrency?: Concurrency | undefined;
}): (elements: Iterable<A>) => Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
B, function (type parameter) E in <A, B, E, R>(f: (a: A, i: number) => Effect<B, E, R>, options?: {
readonly concurrency?: Concurrency | undefined;
}): (elements: Iterable<A>) => Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
E, function (type parameter) R in <A, B, E, R>(f: (a: A, i: number) => Effect<B, E, R>, options?: {
readonly concurrency?: Concurrency | undefined;
}): (elements: Iterable<A>) => Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
R>(
f: (a: A, i: number) => Effect<B, E, R>f: (a: Aa: function (type parameter) A in <A, B, E, R>(f: (a: A, i: number) => Effect<B, E, R>, options?: {
readonly concurrency?: Concurrency | undefined;
}): (elements: Iterable<A>) => Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
A, i: numberi: number) => 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) B in <A, B, E, R>(f: (a: A, i: number) => Effect<B, E, R>, options?: {
readonly concurrency?: Concurrency | undefined;
}): (elements: Iterable<A>) => Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
B, function (type parameter) E in <A, B, E, R>(f: (a: A, i: number) => Effect<B, E, R>, options?: {
readonly concurrency?: Concurrency | undefined;
}): (elements: Iterable<A>) => Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
E, function (type parameter) R in <A, B, E, R>(f: (a: A, i: number) => Effect<B, E, R>, options?: {
readonly concurrency?: Concurrency | undefined;
}): (elements: Iterable<A>) => Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
R>,
options: {
readonly concurrency?: Concurrency | undefined
}
options?: { readonly concurrency?: Concurrency | undefinedconcurrency?: type Concurrency = number | "unbounded" | "inherit"Describes the concurrency level for Effect operations that run multiple
effects.
When to use
Use to type options that control how many effects may run at the same time.
Details
number — run at most N effects concurrently.
"unbounded" — run all effects concurrently with no limit.
"inherit" — inherit the concurrency from the surrounding context.
Example (Setting concurrency values)
import type { Types } from "effect"
const sequential: Types.Concurrency = 1
const limited: Types.Concurrency = 5
const unbounded: Types.Concurrency = "unbounded"
const inherit: Types.Concurrency = "inherit"
Concurrency | undefined }
): (elements: Iterable<A>elements: interface Iterable<T, TReturn = any, TNext = any>Iterable<function (type parameter) A in <A, B, E, R>(f: (a: A, i: number) => Effect<B, E, R>, options?: {
readonly concurrency?: Concurrency | undefined;
}): (elements: Iterable<A>) => Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
A>) => 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<[E[]excluded: interface Array<T>Array<function (type parameter) E in <A, B, E, R>(f: (a: A, i: number) => Effect<B, E, R>, options?: {
readonly concurrency?: Concurrency | undefined;
}): (elements: Iterable<A>) => Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
E>, B[]satisfying: interface Array<T>Array<function (type parameter) B in <A, B, E, R>(f: (a: A, i: number) => Effect<B, E, R>, options?: {
readonly concurrency?: Concurrency | undefined;
}): (elements: Iterable<A>) => Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
B>], never, function (type parameter) R in <A, B, E, R>(f: (a: A, i: number) => Effect<B, E, R>, options?: {
readonly concurrency?: Concurrency | undefined;
}): (elements: Iterable<A>) => Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
R>
<function (type parameter) A in <A, B, E, R>(elements: Iterable<A>, f: (a: A, i: number) => Effect<B, E, R>, options?: {
readonly concurrency?: Concurrency | undefined;
}): Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
A, function (type parameter) B in <A, B, E, R>(elements: Iterable<A>, f: (a: A, i: number) => Effect<B, E, R>, options?: {
readonly concurrency?: Concurrency | undefined;
}): Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
B, function (type parameter) E in <A, B, E, R>(elements: Iterable<A>, f: (a: A, i: number) => Effect<B, E, R>, options?: {
readonly concurrency?: Concurrency | undefined;
}): Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
E, function (type parameter) R in <A, B, E, R>(elements: Iterable<A>, f: (a: A, i: number) => Effect<B, E, R>, options?: {
readonly concurrency?: Concurrency | undefined;
}): Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
R>(
elements: Iterable<A>elements: interface Iterable<T, TReturn = any, TNext = any>Iterable<function (type parameter) A in <A, B, E, R>(elements: Iterable<A>, f: (a: A, i: number) => Effect<B, E, R>, options?: {
readonly concurrency?: Concurrency | undefined;
}): Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
A>,
f: (a: A, i: number) => Effect<B, E, R>f: (a: Aa: function (type parameter) A in <A, B, E, R>(elements: Iterable<A>, f: (a: A, i: number) => Effect<B, E, R>, options?: {
readonly concurrency?: Concurrency | undefined;
}): Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
A, i: numberi: number) => 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) B in <A, B, E, R>(elements: Iterable<A>, f: (a: A, i: number) => Effect<B, E, R>, options?: {
readonly concurrency?: Concurrency | undefined;
}): Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
B, function (type parameter) E in <A, B, E, R>(elements: Iterable<A>, f: (a: A, i: number) => Effect<B, E, R>, options?: {
readonly concurrency?: Concurrency | undefined;
}): Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
E, function (type parameter) R in <A, B, E, R>(elements: Iterable<A>, f: (a: A, i: number) => Effect<B, E, R>, options?: {
readonly concurrency?: Concurrency | undefined;
}): Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
R>,
options: {
readonly concurrency?: Concurrency | undefined
}
options?: { readonly concurrency?: Concurrency | undefinedconcurrency?: type Concurrency = number | "unbounded" | "inherit"Describes the concurrency level for Effect operations that run multiple
effects.
When to use
Use to type options that control how many effects may run at the same time.
Details
number — run at most N effects concurrently.
"unbounded" — run all effects concurrently with no limit.
"inherit" — inherit the concurrency from the surrounding context.
Example (Setting concurrency values)
import type { Types } from "effect"
const sequential: Types.Concurrency = 1
const limited: Types.Concurrency = 5
const unbounded: Types.Concurrency = "unbounded"
const inherit: Types.Concurrency = "inherit"
Concurrency | undefined }
): 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<[E[]excluded: interface Array<T>Array<function (type parameter) E in <A, B, E, R>(elements: Iterable<A>, f: (a: A, i: number) => Effect<B, E, R>, options?: {
readonly concurrency?: Concurrency | undefined;
}): Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
E>, B[]satisfying: interface Array<T>Array<function (type parameter) B in <A, B, E, R>(elements: Iterable<A>, f: (a: A, i: number) => Effect<B, E, R>, options?: {
readonly concurrency?: Concurrency | undefined;
}): Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
B>], never, function (type parameter) R in <A, B, E, R>(elements: Iterable<A>, f: (a: A, i: number) => Effect<B, E, R>, options?: {
readonly concurrency?: Concurrency | undefined;
}): Effect<[excluded: Array<E>, satisfying: Array<B>], never, R>
R>
} = import internalinternal.const partition: {
<A, B, E, R>(
f: (
a: A,
i: number
) => Effect.Effect<B, E, R>,
options?: {
readonly concurrency?:
| Concurrency
| undefined
}
): (
elements: Iterable<A>
) => Effect.Effect<
[excluded: Array<E>, satisfying: Array<B>],
never,
R
>
<A, B, E, R>(
elements: Iterable<A>,
f: (
a: A,
i: number
) => Effect.Effect<B, E, R>,
options?: {
readonly concurrency?:
| Concurrency
| undefined
}
): Effect.Effect<
[excluded: Array<E>, satisfying: Array<B>],
never,
R
>
}
partition