<S extends Constraint, R = never>(
f: (
issue: SchemaIssue.Issue
) => Effect.Effect<Option_.Option<S["Type"]>, SchemaIssue.Issue, R>
): (self: S) => middlewareDecoding<S, S["DecodingServices"] | R>Recovers from a decoding error with a handler that may require Effect services.
When to use
Use when you need decoding fallback logic to require services from the Effect context.
Details
The handler receives the Issue and returns an Effect that either succeeds
with a fallback value or re-fails with a (possibly different) issue. The
handler's services are added to the schema's decoding services.
export function function catchDecodingWithContext<
S extends Constraint,
R = never
>(
f: (
issue: SchemaIssue.Issue
) => Effect.Effect<
Option_.Option<S["Type"]>,
SchemaIssue.Issue,
R
>
): (
self: S
) => middlewareDecoding<
S,
S["DecodingServices"] | R
>
Recovers from a decoding error with a handler that may require Effect services.
When to use
Use when you need decoding fallback logic to require services from the Effect
context.
Details
The handler receives the Issue and returns an Effect that either succeeds
with a fallback value or re-fails with a (possibly different) issue. The
handler's services are added to the schema's decoding services.
catchDecodingWithContext<function (type parameter) S in catchDecodingWithContext<S extends Constraint, R = never>(f: (issue: SchemaIssue.Issue) => Effect.Effect<Option_.Option<S["Type"]>, SchemaIssue.Issue, R>): (self: S) => middlewareDecoding<S, S["DecodingServices"] | R>S extends Constraint, function (type parameter) R in catchDecodingWithContext<S extends Constraint, R = never>(f: (issue: SchemaIssue.Issue) => Effect.Effect<Option_.Option<S["Type"]>, SchemaIssue.Issue, R>): (self: S) => middlewareDecoding<S, S["DecodingServices"] | R>R = never>(
f: (
issue: SchemaIssue.Issue
) => Effect.Effect<
Option_.Option<S["Type"]>,
SchemaIssue.Issue,
R
>
f: (issue: SchemaIssue.Issueissue: import SchemaIssueSchemaIssue.type Issue =
| SchemaIssue.Leaf
| SchemaIssue.Filter
| SchemaIssue.Encoding
| SchemaIssue.Pointer
| SchemaIssue.Composite
| SchemaIssue.AnyOf
The root discriminated union of all validation error nodes.
When to use
Use when typing the error channel in Effect<A, Issue, R> results from
schema parsing, or when writing custom formatters or issue-tree walkers.
Details
Every node has a _tag field for pattern-matching. The union includes both
terminal
Leaf
types and composite types that wrap inner issues:
Filter
,
Encoding
,
Pointer
,
Composite
,
AnyOf
. All Issue instances have a toString() that delegates to
the default formatter, so String(issue) produces a human-readable message.
Issue) => 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<import Option_Option_.type Option<A> = Option_.None<A> | Option_.Some<A>The Option data type represents optional values. An Option<A> is either
Some<A>, containing a value of type A, or None, representing absence.
When to use
Use to represent initial values that may not yet exist
- Returning from partial functions (not defined for all inputs)
- Managing optional fields in data structures
Namespace containing utility types for Option.
When to use
Use to access type-level helpers associated with Option.
Option<function (type parameter) S in catchDecodingWithContext<S extends Constraint, R = never>(f: (issue: SchemaIssue.Issue) => Effect.Effect<Option_.Option<S["Type"]>, SchemaIssue.Issue, R>): (self: S) => middlewareDecoding<S, S["DecodingServices"] | R>S["Type"]>, import SchemaIssueSchemaIssue.type Issue =
| SchemaIssue.Leaf
| SchemaIssue.Filter
| SchemaIssue.Encoding
| SchemaIssue.Pointer
| SchemaIssue.Composite
| SchemaIssue.AnyOf
The root discriminated union of all validation error nodes.
When to use
Use when typing the error channel in Effect<A, Issue, R> results from
schema parsing, or when writing custom formatters or issue-tree walkers.
Details
Every node has a _tag field for pattern-matching. The union includes both
terminal
Leaf
types and composite types that wrap inner issues:
Filter
,
Encoding
,
Pointer
,
Composite
,
AnyOf
. All Issue instances have a toString() that delegates to
the default formatter, so String(issue) produces a human-readable message.
Issue, function (type parameter) R in catchDecodingWithContext<S extends Constraint, R = never>(f: (issue: SchemaIssue.Issue) => Effect.Effect<Option_.Option<S["Type"]>, SchemaIssue.Issue, R>): (self: S) => middlewareDecoding<S, S["DecodingServices"] | R>R>
) {
return (self: S extends Constraintself: function (type parameter) S in catchDecodingWithContext<S extends Constraint, R = never>(f: (issue: SchemaIssue.Issue) => Effect.Effect<Option_.Option<S["Type"]>, SchemaIssue.Issue, R>): (self: S) => middlewareDecoding<S, S["DecodingServices"] | R>S): interface middlewareDecoding<S extends Constraint, RD>Intercepts the decoding pipeline of a schema.
Details
The provided function receives the current decoding Effect and ParseOptions,
and returns a new Effect — potentially adding service requirements (RD),
recovering from errors, or augmenting the result.
Example (Logging decode failures)
import { Effect, Schema } from "effect"
const Logged = Schema.String.pipe(
Schema.middlewareDecoding((effect) =>
Effect.tapError(effect, (issue) => Effect.log("decode failed", issue))
)
)
Type-level representation returned by
middlewareDecoding
.
middlewareDecoding<function (type parameter) S in catchDecodingWithContext<S extends Constraint, R = never>(f: (issue: SchemaIssue.Issue) => Effect.Effect<Option_.Option<S["Type"]>, SchemaIssue.Issue, R>): (self: S) => middlewareDecoding<S, S["DecodingServices"] | R>S, function (type parameter) S in catchDecodingWithContext<S extends Constraint, R = never>(f: (issue: SchemaIssue.Issue) => Effect.Effect<Option_.Option<S["Type"]>, SchemaIssue.Issue, R>): (self: S) => middlewareDecoding<S, S["DecodingServices"] | R>S["DecodingServices"] | function (type parameter) R in catchDecodingWithContext<S extends Constraint, R = never>(f: (issue: SchemaIssue.Issue) => Effect.Effect<Option_.Option<S["Type"]>, SchemaIssue.Issue, R>): (self: S) => middlewareDecoding<S, S["DecodingServices"] | R>R> =>
function middlewareDecoding<
S extends Constraint,
RD
>(
decode: (
effect: Effect.Effect<
Option_.Option<S["Type"]>,
SchemaIssue.Issue,
S["DecodingServices"]
>,
options: SchemaAST.ParseOptions
) => Effect.Effect<
Option_.Option<S["Type"]>,
SchemaIssue.Issue,
RD
>
): (schema: S) => middlewareDecoding<S, RD>
Intercepts the decoding pipeline of a schema.
Details
The provided function receives the current decoding Effect and ParseOptions,
and returns a new Effect — potentially adding service requirements (RD),
recovering from errors, or augmenting the result.
Example (Logging decode failures)
import { Effect, Schema } from "effect"
const Logged = Schema.String.pipe(
Schema.middlewareDecoding((effect) =>
Effect.tapError(effect, (issue) => Effect.log("decode failed", issue))
)
)
middlewareDecoding<function (type parameter) S in catchDecodingWithContext<S extends Constraint, R = never>(f: (issue: SchemaIssue.Issue) => Effect.Effect<Option_.Option<S["Type"]>, SchemaIssue.Issue, R>): (self: S) => middlewareDecoding<S, S["DecodingServices"] | R>S, function (type parameter) S in catchDecodingWithContext<S extends Constraint, R = never>(f: (issue: SchemaIssue.Issue) => Effect.Effect<Option_.Option<S["Type"]>, SchemaIssue.Issue, R>): (self: S) => middlewareDecoding<S, S["DecodingServices"] | R>S["DecodingServices"] | function (type parameter) R in catchDecodingWithContext<S extends Constraint, R = never>(f: (issue: SchemaIssue.Issue) => Effect.Effect<Option_.Option<S["Type"]>, SchemaIssue.Issue, R>): (self: S) => middlewareDecoding<S, S["DecodingServices"] | R>R>(import EffectEffect.const catchEager: {
<E, B, E2, R2>(
f: (e: NoInfer<E>) => Effect<B, E2, R2>
): <A, R>(
self: Effect<A, E, R>
) => Effect<A | B, E2, R | R2>
<A, E, R, B, E2, R2>(
self: Effect<A, E, R>,
f: (e: NoInfer<E>) => Effect<B, E2, R2>
): Effect<A | B, E2, R | R2>
}
catchEager(f: (
issue: SchemaIssue.Issue
) => Effect.Effect<
Option_.Option<S["Type"]>,
SchemaIssue.Issue,
R
>
f))(self: S extends Constraintself)
}