<A2, E2, R2, A, B>(
that: Effect<A2, E2, R2>,
f: (a: A, b: A2) => B,
options?: { readonly concurrent?: boolean | undefined }
): <E, R>(self: Effect<A, E, R>) => Effect<B, E2 | E, R2 | R>
<A, E, R, A2, E2, R2, B>(
self: Effect<A, E, R>,
that: Effect<A2, E2, R2>,
f: (a: A, b: A2) => B,
options?: { readonly concurrent?: boolean | undefined }
): Effect<B, E2 | E, R2 | R>Combines two effects sequentially and applies a function to their results to produce a single value.
When to use
Use when you need to run two effects sequentially and combine their results with a function instead of keeping the results as a tuple.
Details
Concurrency:
By default, the effects are run sequentially. To execute them concurrently,
use the { concurrent: true } option.
Example (Combining two success values with a function)
import { Effect } from "effect"
const task1 = Effect.succeed(1).pipe(
Effect.delay("200 millis"),
Effect.tap(Effect.log("task1 done"))
)
const task2 = Effect.succeed("hello").pipe(
Effect.delay("100 millis"),
Effect.tap(Effect.log("task2 done"))
)
const task3 = Effect.zipWith(
task1,
task2,
// Combines results into a single value
(number, string) => number + string.length
)
Effect.runPromise(task3).then(console.log)
// Output:
// timestamp=... level=INFO fiber=#3 message="task1 done"
// timestamp=... level=INFO fiber=#2 message="task2 done"
// 6export const const zipWith: {
<A2, E2, R2, A, B>(
that: Effect<A2, E2, R2>,
f: (a: A, b: A2) => B,
options?: {
readonly concurrent?: boolean | undefined
}
): <E, R>(
self: Effect<A, E, R>
) => Effect<B, E2 | E, R2 | R>
<A, E, R, A2, E2, R2, B>(
self: Effect<A, E, R>,
that: Effect<A2, E2, R2>,
f: (a: A, b: A2) => B,
options?: {
readonly concurrent?: boolean | undefined
}
): Effect<B, E2 | E, R2 | R>
}
Combines two effects sequentially and applies a function to their results to
produce a single value.
When to use
Use when you need to run two effects sequentially and combine their results
with a function instead of keeping the results as a tuple.
Details
Concurrency:
By default, the effects are run sequentially. To execute them concurrently,
use the { concurrent: true } option.
Example (Combining two success values with a function)
import { Effect } from "effect"
const task1 = Effect.succeed(1).pipe(
Effect.delay("200 millis"),
Effect.tap(Effect.log("task1 done"))
)
const task2 = Effect.succeed("hello").pipe(
Effect.delay("100 millis"),
Effect.tap(Effect.log("task2 done"))
)
const task3 = Effect.zipWith(
task1,
task2,
// Combines results into a single value
(number, string) => number + string.length
)
Effect.runPromise(task3).then(console.log)
// Output:
// timestamp=... level=INFO fiber=#3 message="task1 done"
// timestamp=... level=INFO fiber=#2 message="task2 done"
// 6
zipWith: {
<function (type parameter) A2 in <A2, E2, R2, A, B>(that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): <E, R>(self: Effect<A, E, R>) => Effect<B, E2 | E, R2 | R>
A2, function (type parameter) E2 in <A2, E2, R2, A, B>(that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): <E, R>(self: Effect<A, E, R>) => Effect<B, E2 | E, R2 | R>
E2, function (type parameter) R2 in <A2, E2, R2, A, B>(that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): <E, R>(self: Effect<A, E, R>) => Effect<B, E2 | E, R2 | R>
R2, function (type parameter) A in <A2, E2, R2, A, B>(that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): <E, R>(self: Effect<A, E, R>) => Effect<B, E2 | E, R2 | R>
A, function (type parameter) B in <A2, E2, R2, A, B>(that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): <E, R>(self: Effect<A, E, R>) => Effect<B, E2 | E, R2 | R>
B>(
that: Effect<A2, E2, R2>(parameter) that: {
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;
}
that: 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) A2 in <A2, E2, R2, A, B>(that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): <E, R>(self: Effect<A, E, R>) => Effect<B, E2 | E, R2 | R>
A2, function (type parameter) E2 in <A2, E2, R2, A, B>(that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): <E, R>(self: Effect<A, E, R>) => Effect<B, E2 | E, R2 | R>
E2, function (type parameter) R2 in <A2, E2, R2, A, B>(that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): <E, R>(self: Effect<A, E, R>) => Effect<B, E2 | E, R2 | R>
R2>,
f: (a: A, b: A2) => Bf: (a: Aa: function (type parameter) A in <A2, E2, R2, A, B>(that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): <E, R>(self: Effect<A, E, R>) => Effect<B, E2 | E, R2 | R>
A, b: A2b: function (type parameter) A2 in <A2, E2, R2, A, B>(that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): <E, R>(self: Effect<A, E, R>) => Effect<B, E2 | E, R2 | R>
A2) => function (type parameter) B in <A2, E2, R2, A, B>(that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): <E, R>(self: Effect<A, E, R>) => Effect<B, E2 | E, R2 | R>
B,
options: | {
readonly concurrent?: boolean | undefined
}
| undefined
options?: { readonly concurrent?: boolean | undefinedconcurrent?: boolean | undefined }
): <function (type parameter) E in <E, R>(self: Effect<A, E, R>): Effect<B, E2 | E, R2 | R>E, function (type parameter) R in <E, R>(self: Effect<A, E, R>): Effect<B, E2 | E, R2 | R>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 <A2, E2, R2, A, B>(that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): <E, R>(self: Effect<A, E, R>) => Effect<B, E2 | E, R2 | R>
A, function (type parameter) E in <E, R>(self: Effect<A, E, R>): Effect<B, E2 | E, R2 | R>E, function (type parameter) R in <E, R>(self: Effect<A, E, R>): Effect<B, E2 | E, R2 | R>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) B in <A2, E2, R2, A, B>(that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): <E, R>(self: Effect<A, E, R>) => Effect<B, E2 | E, R2 | R>
B, function (type parameter) E2 in <A2, E2, R2, A, B>(that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): <E, R>(self: Effect<A, E, R>) => Effect<B, E2 | E, R2 | R>
E2 | function (type parameter) E in <E, R>(self: Effect<A, E, R>): Effect<B, E2 | E, R2 | R>E, function (type parameter) R2 in <A2, E2, R2, A, B>(that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): <E, R>(self: Effect<A, E, R>) => Effect<B, E2 | E, R2 | R>
R2 | function (type parameter) R in <E, R>(self: Effect<A, E, R>): Effect<B, E2 | E, R2 | R>R>
<function (type parameter) A in <A, E, R, A2, E2, R2, B>(self: Effect<A, E, R>, that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): Effect<B, E2 | E, R2 | R>
A, function (type parameter) E in <A, E, R, A2, E2, R2, B>(self: Effect<A, E, R>, that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): Effect<B, E2 | E, R2 | R>
E, function (type parameter) R in <A, E, R, A2, E2, R2, B>(self: Effect<A, E, R>, that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): Effect<B, E2 | E, R2 | R>
R, function (type parameter) A2 in <A, E, R, A2, E2, R2, B>(self: Effect<A, E, R>, that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): Effect<B, E2 | E, R2 | R>
A2, function (type parameter) E2 in <A, E, R, A2, E2, R2, B>(self: Effect<A, E, R>, that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): Effect<B, E2 | E, R2 | R>
E2, function (type parameter) R2 in <A, E, R, A2, E2, R2, B>(self: Effect<A, E, R>, that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): Effect<B, E2 | E, R2 | R>
R2, function (type parameter) B in <A, E, R, A2, E2, R2, B>(self: Effect<A, E, R>, that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): Effect<B, E2 | E, R2 | R>
B>(
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, A2, E2, R2, B>(self: Effect<A, E, R>, that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): Effect<B, E2 | E, R2 | R>
A, function (type parameter) E in <A, E, R, A2, E2, R2, B>(self: Effect<A, E, R>, that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): Effect<B, E2 | E, R2 | R>
E, function (type parameter) R in <A, E, R, A2, E2, R2, B>(self: Effect<A, E, R>, that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): Effect<B, E2 | E, R2 | R>
R>,
that: Effect<A2, E2, R2>(parameter) that: {
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;
}
that: 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) A2 in <A, E, R, A2, E2, R2, B>(self: Effect<A, E, R>, that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): Effect<B, E2 | E, R2 | R>
A2, function (type parameter) E2 in <A, E, R, A2, E2, R2, B>(self: Effect<A, E, R>, that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): Effect<B, E2 | E, R2 | R>
E2, function (type parameter) R2 in <A, E, R, A2, E2, R2, B>(self: Effect<A, E, R>, that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): Effect<B, E2 | E, R2 | R>
R2>,
f: (a: A, b: A2) => Bf: (a: Aa: function (type parameter) A in <A, E, R, A2, E2, R2, B>(self: Effect<A, E, R>, that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): Effect<B, E2 | E, R2 | R>
A, b: A2b: function (type parameter) A2 in <A, E, R, A2, E2, R2, B>(self: Effect<A, E, R>, that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): Effect<B, E2 | E, R2 | R>
A2) => function (type parameter) B in <A, E, R, A2, E2, R2, B>(self: Effect<A, E, R>, that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): Effect<B, E2 | E, R2 | R>
B,
options: | {
readonly concurrent?: boolean | undefined
}
| undefined
options?: { readonly concurrent?: boolean | undefinedconcurrent?: boolean | 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<function (type parameter) B in <A, E, R, A2, E2, R2, B>(self: Effect<A, E, R>, that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): Effect<B, E2 | E, R2 | R>
B, function (type parameter) E2 in <A, E, R, A2, E2, R2, B>(self: Effect<A, E, R>, that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): Effect<B, E2 | E, R2 | R>
E2 | function (type parameter) E in <A, E, R, A2, E2, R2, B>(self: Effect<A, E, R>, that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): Effect<B, E2 | E, R2 | R>
E, function (type parameter) R2 in <A, E, R, A2, E2, R2, B>(self: Effect<A, E, R>, that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): Effect<B, E2 | E, R2 | R>
R2 | function (type parameter) R in <A, E, R, A2, E2, R2, B>(self: Effect<A, E, R>, that: Effect<A2, E2, R2>, f: (a: A, b: A2) => B, options?: {
readonly concurrent?: boolean | undefined;
}): Effect<B, E2 | E, R2 | R>
R>
} = import internalinternal.const zipWith: {
<A2, E2, R2, A, B>(
that: Effect.Effect<A2, E2, R2>,
f: (a: A, b: A2) => B,
options?: {
readonly concurrent?: boolean | undefined
}
): <E, R>(
self: Effect.Effect<A, E, R>
) => Effect.Effect<B, E2 | E, R2 | R>
<A, E, R, A2, E2, R2, B>(
self: Effect.Effect<A, E, R>,
that: Effect.Effect<A2, E2, R2>,
f: (a: A, b: A2) => B,
options?: {
readonly concurrent?: boolean | undefined
}
): Effect.Effect<B, E2 | E, R2 | R>
}
zipWith