<S extends Schema.ConstraintEncoder<unknown>>(
schema: S,
options?: SchemaAST.ParseOptions
): (
input: S["Type"],
options?: SchemaAST.ParseOptions
) => Exit.Exit<S["Encoded"], SchemaIssue.Issue>Creates a synchronous encoder for input already typed as the schema's decoded
Type, reporting failure safely as an Exit.
When to use
Use when you need synchronous encoding of already typed schema values into
an Exit whose failure contains SchemaIssue.Issue.
Details
The returned function produces Exit.Success with the schema's Encoded value
or Exit.Failure with a SchemaIssue.Issue.
Gotchas
Because this adapter runs synchronously, async encoding work can produce an
Exit.Failure with a defect cause. When the cause contains both schema
issues and non-schema reasons, all reasons remain in the returned Cause.
export const const encodeExit: <
S extends Schema.ConstraintEncoder<unknown>
>(
schema: S,
options?: SchemaAST.ParseOptions
) => (
input: S["Type"],
options?: SchemaAST.ParseOptions
) => Exit.Exit<S["Encoded"], SchemaIssue.Issue>
Creates a synchronous encoder for input already typed as the schema's decoded
Type, reporting failure safely as an Exit.
When to use
Use when you need synchronous encoding of already typed schema values into
an Exit whose failure contains SchemaIssue.Issue.
Details
The returned function produces Exit.Success with the schema's Encoded value
or Exit.Failure with a SchemaIssue.Issue.
Gotchas
Because this adapter runs synchronously, async encoding work can produce an
Exit.Failure with a defect cause. When the cause contains both schema
issues and non-schema reasons, all reasons remain in the returned Cause.
encodeExit: <function (type parameter) S in <S extends Schema.ConstraintEncoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: S["Type"], options?: SchemaAST.ParseOptions) => Exit.Exit<S["Encoded"], SchemaIssue.Issue>S extends import SchemaSchema.interface ConstraintEncoder<out E, out RE = never>Lightweight structural constraint for APIs that need encoder type views but
do not need the full schema protocol.
When to use
Use when you need to preserve a schema's encoded type and encoding services,
but the API does not constrain the decoded type, decoding services, or call
schema methods such as annotate, check, rebuild, make, or
makeEffect.
ConstraintEncoder<unknown>>(
schema: S extends Schema.ConstraintEncoder<unknown>schema: function (type parameter) S in <S extends Schema.ConstraintEncoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: S["Type"], options?: SchemaAST.ParseOptions) => Exit.Exit<S["Encoded"], SchemaIssue.Issue>S,
options: SchemaAST.ParseOptionsoptions?: import SchemaASTSchemaAST.ParseOptions
) => (input: S["Type"]input: function (type parameter) S in <S extends Schema.ConstraintEncoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: S["Type"], options?: SchemaAST.ParseOptions) => Exit.Exit<S["Encoded"], SchemaIssue.Issue>S["Type"], options: SchemaAST.ParseOptionsoptions?: import SchemaASTSchemaAST.ParseOptions) => import ExitExit.type Exit<A, E = never> = Exit.Success<A, E> | Exit.Failure<A, E>Represents the result of an Effect computation.
When to use
Use when you need to synchronously inspect whether an Effect computation
succeeded or failed.
Details
An Exit<A, E> is either Success<A, E> containing a value of type A, or
Failure<A, E> containing a Cause<E> describing why the computation
failed.
Since Exit is also an Effect, you can yield it inside Effect.gen.
Example (Pattern matching on an Exit)
import { Exit } from "effect"
const success: Exit.Exit<number> = Exit.succeed(42)
const failure: Exit.Exit<number, string> = Exit.fail("error")
const result = Exit.match(success, {
onSuccess: (value) => `Got value: ${value}`,
onFailure: (cause) => `Got error: ${cause}`
})
Namespace containing helper types shared by Exit values.
When to use
Use to reference helper types that describe the shared structure of Exit
values.
Exit<function (type parameter) S in <S extends Schema.ConstraintEncoder<unknown>>(schema: S, options?: SchemaAST.ParseOptions): (input: S["Type"], options?: SchemaAST.ParseOptions) => Exit.Exit<S["Encoded"], SchemaIssue.Issue>S["Encoded"], 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 encodeUnknownExit<
S extends Schema.ConstraintEncoder<unknown>
>(
schema: S,
options?: SchemaAST.ParseOptions
): (
input: unknown,
options?: SchemaAST.ParseOptions
) => Exit.Exit<S["Encoded"], SchemaIssue.Issue>
Creates a synchronous encoder for unknown input that reports failure safely
as an Exit.
When to use
Use when you need synchronous encoding of unknown input into an Exit whose
failure contains SchemaIssue.Issue.
Details
The returned function produces Exit.Success with the schema's Encoded value
or Exit.Failure with a SchemaIssue.Issue.
Gotchas
Because this adapter runs synchronously, async encoding work can produce an
Exit.Failure with a defect cause. When the cause contains both schema
issues and non-schema reasons, all reasons remain in the returned Cause.
encodeUnknownExit