<E, A2, E2, R2, A, A3, E3, R3>(options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>
readonly onSuccess: (a: A) => Effect<A3, E3, R3>
}): <R>(self: Effect<A, E, R>) => Effect<A2 | A3, E2 | E3, R2 | R3 | R>
<A, E, R, A2, E2, R2, A3, E3, R3>(
self: Effect<A, E, R>,
options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>
readonly onSuccess: (a: A) => Effect<A3, E3, R3>
}
): Effect<A2 | A3, E2 | E3, R2 | R3 | R>Handles both success and failure by running effectful handlers.
When to use
Use when you need to handle an Effect's failure or success with handlers
that return effects.
Details
Use matchEffect when either branch needs to return an Effect, such as
performing logging, recovery, notification, or other effectful work. The
returned effect succeeds or fails according to the handler that is run.
Example (Matching success and failure with effectful handlers)
import { Data, Effect } from "effect"
class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
const failure: Effect.Effect<number, ExampleError> = Effect.fail(
new ExampleError({ message: "Uh oh!" })
)
const program1 = Effect.matchEffect(success, {
onFailure: (error) =>
Effect.succeed(`failure: ${error.message}`).pipe(
Effect.tap(Effect.log)
),
onSuccess: (value) =>
Effect.succeed(`success: ${value}`).pipe(Effect.tap(Effect.log))
})
console.log(Effect.runSync(program1))
// Output:
// timestamp=... level=INFO fiber=#0 message="success: 42"
// success: 42
const program2 = Effect.matchEffect(failure, {
onFailure: (error) =>
Effect.succeed(`failure: ${error.message}`).pipe(
Effect.tap(Effect.log)
),
onSuccess: (value) =>
Effect.succeed(`success: ${value}`).pipe(Effect.tap(Effect.log))
})
console.log(Effect.runSync(program2))
// Output:
// timestamp=... level=INFO fiber=#1 message="failure: Uh oh!"
// failure: Uh oh!export const const matchEffect: {
<E, A2, E2, R2, A, A3, E3, R3>(options: {
readonly onFailure: (
e: E
) => Effect<A2, E2, R2>
readonly onSuccess: (
a: A
) => Effect<A3, E3, R3>
}): <R>(
self: Effect<A, E, R>
) => Effect<A2 | A3, E2 | E3, R2 | R3 | R>
<A, E, R, A2, E2, R2, A3, E3, R3>(
self: Effect<A, E, R>,
options: {
readonly onFailure: (
e: E
) => Effect<A2, E2, R2>
readonly onSuccess: (
a: A
) => Effect<A3, E3, R3>
}
): Effect<A2 | A3, E2 | E3, R2 | R3 | R>
}
Handles both success and failure by running effectful handlers.
When to use
Use when you need to handle an Effect's failure or success with handlers
that return effects.
Details
Use matchEffect when either branch needs to return an Effect, such as
performing logging, recovery, notification, or other effectful work. The
returned effect succeeds or fails according to the handler that is run.
Example (Matching success and failure with effectful handlers)
import { Data, Effect } from "effect"
class ExampleError extends Data.TaggedError("ExampleError")<{ readonly message: string }> {}
const success: Effect.Effect<number, ExampleError> = Effect.succeed(42)
const failure: Effect.Effect<number, ExampleError> = Effect.fail(
new ExampleError({ message: "Uh oh!" })
)
const program1 = Effect.matchEffect(success, {
onFailure: (error) =>
Effect.succeed(`failure: ${error.message}`).pipe(
Effect.tap(Effect.log)
),
onSuccess: (value) =>
Effect.succeed(`success: ${value}`).pipe(Effect.tap(Effect.log))
})
console.log(Effect.runSync(program1))
// Output:
// timestamp=... level=INFO fiber=#0 message="success: 42"
// success: 42
const program2 = Effect.matchEffect(failure, {
onFailure: (error) =>
Effect.succeed(`failure: ${error.message}`).pipe(
Effect.tap(Effect.log)
),
onSuccess: (value) =>
Effect.succeed(`success: ${value}`).pipe(Effect.tap(Effect.log))
})
console.log(Effect.runSync(program2))
// Output:
// timestamp=... level=INFO fiber=#1 message="failure: Uh oh!"
// failure: Uh oh!
matchEffect: {
<function (type parameter) E in <E, A2, E2, R2, A, A3, E3, R3>(options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): <R>(self: Effect<A, E, R>) => Effect<A2 | A3, E2 | E3, R2 | R3 | R>
E, function (type parameter) A2 in <E, A2, E2, R2, A, A3, E3, R3>(options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): <R>(self: Effect<A, E, R>) => Effect<A2 | A3, E2 | E3, R2 | R3 | R>
A2, function (type parameter) E2 in <E, A2, E2, R2, A, A3, E3, R3>(options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): <R>(self: Effect<A, E, R>) => Effect<A2 | A3, E2 | E3, R2 | R3 | R>
E2, function (type parameter) R2 in <E, A2, E2, R2, A, A3, E3, R3>(options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): <R>(self: Effect<A, E, R>) => Effect<A2 | A3, E2 | E3, R2 | R3 | R>
R2, function (type parameter) A in <E, A2, E2, R2, A, A3, E3, R3>(options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): <R>(self: Effect<A, E, R>) => Effect<A2 | A3, E2 | E3, R2 | R3 | R>
A, function (type parameter) A3 in <E, A2, E2, R2, A, A3, E3, R3>(options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): <R>(self: Effect<A, E, R>) => Effect<A2 | A3, E2 | E3, R2 | R3 | R>
A3, function (type parameter) E3 in <E, A2, E2, R2, A, A3, E3, R3>(options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): <R>(self: Effect<A, E, R>) => Effect<A2 | A3, E2 | E3, R2 | R3 | R>
E3, function (type parameter) R3 in <E, A2, E2, R2, A, A3, E3, R3>(options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): <R>(self: Effect<A, E, R>) => Effect<A2 | A3, E2 | E3, R2 | R3 | R>
R3>(options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>
readonly onSuccess: (a: A) => Effect<A3, E3, R3>
}
options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>onFailure: (e: Ee: function (type parameter) E in <E, A2, E2, R2, A, A3, E3, R3>(options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): <R>(self: Effect<A, E, R>) => Effect<A2 | A3, E2 | E3, R2 | R3 | R>
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<function (type parameter) A2 in <E, A2, E2, R2, A, A3, E3, R3>(options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): <R>(self: Effect<A, E, R>) => Effect<A2 | A3, E2 | E3, R2 | R3 | R>
A2, function (type parameter) E2 in <E, A2, E2, R2, A, A3, E3, R3>(options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): <R>(self: Effect<A, E, R>) => Effect<A2 | A3, E2 | E3, R2 | R3 | R>
E2, function (type parameter) R2 in <E, A2, E2, R2, A, A3, E3, R3>(options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): <R>(self: Effect<A, E, R>) => Effect<A2 | A3, E2 | E3, R2 | R3 | R>
R2>
readonly onSuccess: (a: A) => Effect<A3, E3, R3>onSuccess: (a: Aa: function (type parameter) A in <E, A2, E2, R2, A, A3, E3, R3>(options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): <R>(self: Effect<A, E, R>) => Effect<A2 | A3, E2 | E3, R2 | R3 | 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<function (type parameter) A3 in <E, A2, E2, R2, A, A3, E3, R3>(options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): <R>(self: Effect<A, E, R>) => Effect<A2 | A3, E2 | E3, R2 | R3 | R>
A3, function (type parameter) E3 in <E, A2, E2, R2, A, A3, E3, R3>(options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): <R>(self: Effect<A, E, R>) => Effect<A2 | A3, E2 | E3, R2 | R3 | R>
E3, function (type parameter) R3 in <E, A2, E2, R2, A, A3, E3, R3>(options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): <R>(self: Effect<A, E, R>) => Effect<A2 | A3, E2 | E3, R2 | R3 | R>
R3>
}): <function (type parameter) R in <R>(self: Effect<A, E, R>): Effect<A2 | A3, E2 | E3, R2 | R3 | 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 <E, A2, E2, R2, A, A3, E3, R3>(options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): <R>(self: Effect<A, E, R>) => Effect<A2 | A3, E2 | E3, R2 | R3 | R>
A, function (type parameter) E in <E, A2, E2, R2, A, A3, E3, R3>(options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): <R>(self: Effect<A, E, R>) => Effect<A2 | A3, E2 | E3, R2 | R3 | R>
E, function (type parameter) R in <R>(self: Effect<A, E, R>): Effect<A2 | A3, E2 | E3, R2 | R3 | 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) A2 in <E, A2, E2, R2, A, A3, E3, R3>(options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): <R>(self: Effect<A, E, R>) => Effect<A2 | A3, E2 | E3, R2 | R3 | R>
A2 | function (type parameter) A3 in <E, A2, E2, R2, A, A3, E3, R3>(options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): <R>(self: Effect<A, E, R>) => Effect<A2 | A3, E2 | E3, R2 | R3 | R>
A3, function (type parameter) E2 in <E, A2, E2, R2, A, A3, E3, R3>(options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): <R>(self: Effect<A, E, R>) => Effect<A2 | A3, E2 | E3, R2 | R3 | R>
E2 | function (type parameter) E3 in <E, A2, E2, R2, A, A3, E3, R3>(options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): <R>(self: Effect<A, E, R>) => Effect<A2 | A3, E2 | E3, R2 | R3 | R>
E3, function (type parameter) R2 in <E, A2, E2, R2, A, A3, E3, R3>(options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): <R>(self: Effect<A, E, R>) => Effect<A2 | A3, E2 | E3, R2 | R3 | R>
R2 | function (type parameter) R3 in <E, A2, E2, R2, A, A3, E3, R3>(options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): <R>(self: Effect<A, E, R>) => Effect<A2 | A3, E2 | E3, R2 | R3 | R>
R3 | function (type parameter) R in <R>(self: Effect<A, E, R>): Effect<A2 | A3, E2 | E3, R2 | R3 | R>R>
<function (type parameter) A in <A, E, R, A2, E2, R2, A3, E3, R3>(self: Effect<A, E, R>, options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): Effect<A2 | A3, E2 | E3, R2 | R3 | R>
A, function (type parameter) E in <A, E, R, A2, E2, R2, A3, E3, R3>(self: Effect<A, E, R>, options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): Effect<A2 | A3, E2 | E3, R2 | R3 | R>
E, function (type parameter) R in <A, E, R, A2, E2, R2, A3, E3, R3>(self: Effect<A, E, R>, options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): Effect<A2 | A3, E2 | E3, R2 | R3 | R>
R, function (type parameter) A2 in <A, E, R, A2, E2, R2, A3, E3, R3>(self: Effect<A, E, R>, options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): Effect<A2 | A3, E2 | E3, R2 | R3 | R>
A2, function (type parameter) E2 in <A, E, R, A2, E2, R2, A3, E3, R3>(self: Effect<A, E, R>, options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): Effect<A2 | A3, E2 | E3, R2 | R3 | R>
E2, function (type parameter) R2 in <A, E, R, A2, E2, R2, A3, E3, R3>(self: Effect<A, E, R>, options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): Effect<A2 | A3, E2 | E3, R2 | R3 | R>
R2, function (type parameter) A3 in <A, E, R, A2, E2, R2, A3, E3, R3>(self: Effect<A, E, R>, options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): Effect<A2 | A3, E2 | E3, R2 | R3 | R>
A3, function (type parameter) E3 in <A, E, R, A2, E2, R2, A3, E3, R3>(self: Effect<A, E, R>, options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): Effect<A2 | A3, E2 | E3, R2 | R3 | R>
E3, function (type parameter) R3 in <A, E, R, A2, E2, R2, A3, E3, R3>(self: Effect<A, E, R>, options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): Effect<A2 | A3, E2 | E3, R2 | R3 | R>
R3>(
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, A3, E3, R3>(self: Effect<A, E, R>, options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): Effect<A2 | A3, E2 | E3, R2 | R3 | R>
A, function (type parameter) E in <A, E, R, A2, E2, R2, A3, E3, R3>(self: Effect<A, E, R>, options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): Effect<A2 | A3, E2 | E3, R2 | R3 | R>
E, function (type parameter) R in <A, E, R, A2, E2, R2, A3, E3, R3>(self: Effect<A, E, R>, options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): Effect<A2 | A3, E2 | E3, R2 | R3 | R>
R>,
options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>
readonly onSuccess: (a: A) => Effect<A3, E3, R3>
}
options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>onFailure: (e: Ee: function (type parameter) E in <A, E, R, A2, E2, R2, A3, E3, R3>(self: Effect<A, E, R>, options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): Effect<A2 | A3, E2 | E3, R2 | R3 | R>
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<function (type parameter) A2 in <A, E, R, A2, E2, R2, A3, E3, R3>(self: Effect<A, E, R>, options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): Effect<A2 | A3, E2 | E3, R2 | R3 | R>
A2, function (type parameter) E2 in <A, E, R, A2, E2, R2, A3, E3, R3>(self: Effect<A, E, R>, options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): Effect<A2 | A3, E2 | E3, R2 | R3 | R>
E2, function (type parameter) R2 in <A, E, R, A2, E2, R2, A3, E3, R3>(self: Effect<A, E, R>, options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): Effect<A2 | A3, E2 | E3, R2 | R3 | R>
R2>
readonly onSuccess: (a: A) => Effect<A3, E3, R3>onSuccess: (a: Aa: function (type parameter) A in <A, E, R, A2, E2, R2, A3, E3, R3>(self: Effect<A, E, R>, options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): Effect<A2 | A3, E2 | E3, R2 | R3 | 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<function (type parameter) A3 in <A, E, R, A2, E2, R2, A3, E3, R3>(self: Effect<A, E, R>, options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): Effect<A2 | A3, E2 | E3, R2 | R3 | R>
A3, function (type parameter) E3 in <A, E, R, A2, E2, R2, A3, E3, R3>(self: Effect<A, E, R>, options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): Effect<A2 | A3, E2 | E3, R2 | R3 | R>
E3, function (type parameter) R3 in <A, E, R, A2, E2, R2, A3, E3, R3>(self: Effect<A, E, R>, options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): Effect<A2 | A3, E2 | E3, R2 | R3 | R>
R3>
}
): 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, A3, E3, R3>(self: Effect<A, E, R>, options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): Effect<A2 | A3, E2 | E3, R2 | R3 | R>
A2 | function (type parameter) A3 in <A, E, R, A2, E2, R2, A3, E3, R3>(self: Effect<A, E, R>, options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): Effect<A2 | A3, E2 | E3, R2 | R3 | R>
A3, function (type parameter) E2 in <A, E, R, A2, E2, R2, A3, E3, R3>(self: Effect<A, E, R>, options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): Effect<A2 | A3, E2 | E3, R2 | R3 | R>
E2 | function (type parameter) E3 in <A, E, R, A2, E2, R2, A3, E3, R3>(self: Effect<A, E, R>, options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): Effect<A2 | A3, E2 | E3, R2 | R3 | R>
E3, function (type parameter) R2 in <A, E, R, A2, E2, R2, A3, E3, R3>(self: Effect<A, E, R>, options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): Effect<A2 | A3, E2 | E3, R2 | R3 | R>
R2 | function (type parameter) R3 in <A, E, R, A2, E2, R2, A3, E3, R3>(self: Effect<A, E, R>, options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): Effect<A2 | A3, E2 | E3, R2 | R3 | R>
R3 | function (type parameter) R in <A, E, R, A2, E2, R2, A3, E3, R3>(self: Effect<A, E, R>, options: {
readonly onFailure: (e: E) => Effect<A2, E2, R2>;
readonly onSuccess: (a: A) => Effect<A3, E3, R3>;
}): Effect<A2 | A3, E2 | E3, R2 | R3 | R>
R>
} = import internalinternal.const matchEffect: {
<E, A2, E2, R2, A, A3, E3, R3>(options: {
readonly onFailure: (
e: E
) => Effect.Effect<A2, E2, R2>
readonly onSuccess: (
a: A
) => Effect.Effect<A3, E3, R3>
}): <R>(
self: Effect.Effect<A, E, R>
) => Effect.Effect<
A2 | A3,
E2 | E3,
R2 | R3 | R
>
<A, E, R, A2, E2, R2, A3, E3, R3>(
self: Effect.Effect<A, E, R>,
options: {
readonly onFailure: (
e: E
) => Effect.Effect<A2, E2, R2>
readonly onSuccess: (
a: A
) => Effect.Effect<A3, E3, R3>
}
): Effect.Effect<A2 | A3, E2 | E3, R2 | R3 | R>
}
matchEffect