Exit<A, E, D>Creates a schema for Exit values using schemas for the success value, typed
failure, and unexpected defect channels.
When to use
Use when serializing or validating an effect outcome where success, typed failure, and defects each need their own schema.
export interface interface Exit<A extends Constraint, E extends Constraint, D extends Constraint>Creates a schema for Exit values using schemas for the success value, typed
failure, and unexpected defect channels.
When to use
Use when serializing or validating an effect outcome where success, typed
failure, and defects each need their own schema.
Type-level representation returned by
Exit
.
Exit<function (type parameter) A in Exit<A extends Constraint, E extends Constraint, D extends Constraint>A extends Constraint, function (type parameter) E in Exit<A extends Constraint, E extends Constraint, D extends Constraint>E extends Constraint, function (type parameter) D in Exit<A extends Constraint, E extends Constraint, D extends Constraint>D extends Constraint> extends
interface declareConstructor<T, E, TypeParameters extends ReadonlyArray<Constraint>, Iso = T>Creates a schema for a parametric type (a generic container such as
Array<A>, Option<A>, etc.) by accepting a list of type-parameter schemas
and a decoder factory.
When to use
Use when you are defining a schema for a generic container whose validation
depends on one or more type-parameter schemas.
Details
The outer call declareConstructor<T, E, Iso>() fixes the decoded type T,
the encoded type E, and the optional iso type. The inner call receives:
typeParameters — the concrete schemas for each type variable
run — a factory that, given resolved codecs for each type parameter,
returns a parsing function (u, ast, options) => Effect<T, Issue>
annotations — optional metadata
Type-level representation returned by
declareConstructor
.
declareConstructor<
import Exit_Exit_.type Exit_.Exit = /*unresolved*/ anyExit<function (type parameter) A in Exit<A extends Constraint, E extends Constraint, D extends Constraint>A["Type"], function (type parameter) E in Exit<A extends Constraint, E extends Constraint, D extends Constraint>E["Type"]>,
import Exit_Exit_.type Exit_.Exit = /*unresolved*/ anyExit<function (type parameter) A in Exit<A extends Constraint, E extends Constraint, D extends Constraint>A["Encoded"], function (type parameter) E in Exit<A extends Constraint, E extends Constraint, D extends Constraint>E["Encoded"]>,
readonly [function (type parameter) A in Exit<A extends Constraint, E extends Constraint, D extends Constraint>A, function (type parameter) E in Exit<A extends Constraint, E extends Constraint, D extends Constraint>E, function (type parameter) D in Exit<A extends Constraint, E extends Constraint, D extends Constraint>D],
type ExitIso<
A extends Constraint,
E extends Constraint,
D extends Constraint
> =
| {
readonly _tag: "Success"
readonly value: A["Iso"]
}
| {
readonly _tag: "Failure"
readonly cause: CauseIso<E, D>
}
Iso representation used for Exit schemas.
Details
Successful exits are represented as { _tag: "Success", value }, while failed
exits are represented as { _tag: "Failure", cause }.
ExitIso<function (type parameter) A in Exit<A extends Constraint, E extends Constraint, D extends Constraint>A, function (type parameter) E in Exit<A extends Constraint, E extends Constraint, D extends Constraint>E, function (type parameter) D in Exit<A extends Constraint, E extends Constraint, D extends Constraint>D>
>
{
readonly "Rebuild": interface Exit<A extends Constraint, E extends Constraint, D extends Constraint>Creates a schema for Exit values using schemas for the success value, typed
failure, and unexpected defect channels.
When to use
Use when serializing or validating an effect outcome where success, typed
failure, and defects each need their own schema.
Type-level representation returned by
Exit
.
Exit<function (type parameter) A in Exit<A extends Constraint, E extends Constraint, D extends Constraint>A, function (type parameter) E in Exit<A extends Constraint, E extends Constraint, D extends Constraint>E, function (type parameter) D in Exit<A extends Constraint, E extends Constraint, D extends Constraint>D>
readonly Exit<A extends Constraint, E extends Constraint, D extends Constraint>.value: A extends Constraintvalue: function (type parameter) A in Exit<A extends Constraint, E extends Constraint, D extends Constraint>A
readonly Exit<A extends Constraint, E extends Constraint, D extends Constraint>.error: E extends Constrainterror: function (type parameter) E in Exit<A extends Constraint, E extends Constraint, D extends Constraint>E
readonly Exit<A extends Constraint, E extends Constraint, D extends Constraint>.defect: D extends Constraintdefect: function (type parameter) D in Exit<A extends Constraint, E extends Constraint, D extends Constraint>D
}
/**
* Iso representation used for `Exit` schemas.
*
* **Details**
*
* Successful exits are represented as `{ _tag: "Success", value }`, while failed
* exits are represented as `{ _tag: "Failure", cause }`.
*
* @category Exit
* @since 4.0.0
*/
export type type ExitIso<
A extends Constraint,
E extends Constraint,
D extends Constraint
> =
| {
readonly _tag: "Success"
readonly value: A["Iso"]
}
| {
readonly _tag: "Failure"
readonly cause: CauseIso<E, D>
}
Iso representation used for Exit schemas.
Details
Successful exits are represented as { _tag: "Success", value }, while failed
exits are represented as { _tag: "Failure", cause }.
ExitIso<function (type parameter) A in type ExitIso<A extends Constraint, E extends Constraint, D extends Constraint>A extends Constraint, function (type parameter) E in type ExitIso<A extends Constraint, E extends Constraint, D extends Constraint>E extends Constraint, function (type parameter) D in type ExitIso<A extends Constraint, E extends Constraint, D extends Constraint>D extends Constraint> = {
readonly _tag: "Success"_tag: "Success"
readonly value: A["Iso"]value: function (type parameter) A in type ExitIso<A extends Constraint, E extends Constraint, D extends Constraint>A["Iso"]
} | {
readonly _tag: "Failure"_tag: "Failure"
readonly cause: CauseIso<E, D>(property) cause: {
length: number;
toString: () => string;
toLocaleString: { (): string; (locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string };
concat: { (...items: Array<ConcatArray<CauseReasonIso<E, D>>>): Array<CauseReasonIso<E, D>>; (...items: Array<CauseReasonIso<E, D> | ConcatArray<CauseReasonIso<E, D>>>): Array<CauseReasonIso<E, D>> };
join: (separator?: string) => string;
slice: (start?: number, end?: number) => Array<CauseReasonIso<E, D>>;
indexOf: (searchElement: CauseReasonIso<E, D>, fromIndex?: number) => number;
lastIndexOf: (searchElement: CauseReasonIso<E, D>, fromIndex?: number) => number;
every: { (predicate: (value: CauseReasonIso<E, D>, index: number, array: ReadonlyArray<CauseReasonIso<E, D>>) => value is S, thisArg?: any): this is readonly S[]; (predicate: (value: CauseReasonIso<E, D>, index: number, array: ReadonlyArray<Cause…;
some: (predicate: (value: CauseReasonIso<E, D>, index: number, array: ReadonlyArray<CauseReasonIso<E, D>>) => unknown, thisArg?: any) => boolean;
forEach: (callbackfn: (value: CauseReasonIso<E, D>, index: number, array: ReadonlyArray<CauseReasonIso<E, D>>) => void, thisArg?: any) => void;
map: (callbackfn: (value: CauseReasonIso<E, D>, index: number, array: ReadonlyArray<CauseReasonIso<E, D>>) => U, thisArg?: any) => Array<U>;
filter: { (predicate: (value: CauseReasonIso<E, D>, index: number, array: ReadonlyArray<CauseReasonIso<E, D>>) => value is S, thisArg?: any): Array<S>; (predicate: (value: CauseReasonIso<E, D>, index: number, array: ReadonlyArray<CauseReasonIso<E,…;
reduce: { (callbackfn: (previousValue: CauseReasonIso<E, D>, currentValue: CauseReasonIso<E, D>, currentIndex: number, array: ReadonlyArray<CauseReasonIso<E, D>>) => CauseReasonIso<E, D>): CauseReasonIso<E, D>; (callbackfn: (previousValue: CauseRe…;
reduceRight: { (callbackfn: (previousValue: CauseReasonIso<E, D>, currentValue: CauseReasonIso<E, D>, currentIndex: number, array: ReadonlyArray<CauseReasonIso<E, D>>) => CauseReasonIso<E, D>): CauseReasonIso<E, D>; (callbackfn: (previousValue: CauseRe…;
find: { (predicate: (value: CauseReasonIso<E, D>, index: number, obj: ReadonlyArray<CauseReasonIso<E, D>>) => value is S, thisArg?: any): S | undefined; (predicate: (value: CauseReasonIso<E, D>, index: number, obj: ReadonlyArray<CauseReasonIso<E…;
findIndex: (predicate: (value: CauseReasonIso<E, D>, index: number, obj: ReadonlyArray<CauseReasonIso<E, D>>) => unknown, thisArg?: any) => number;
entries: () => ArrayIterator<[number, CauseReasonIso<E, D>]>;
keys: () => ArrayIterator<number>;
values: () => ArrayIterator<CauseReasonIso<E, D>>;
includes: (searchElement: CauseReasonIso<E, D>, fromIndex?: number) => boolean;
flatMap: (callback: (this: This, value: CauseReasonIso<E, D>, index: number, array: Array<CauseReasonIso<E, D>>) => U | ReadonlyArray<U>, thisArg?: This | undefined) => Array<U>;
flat: (this: A, depth?: D | undefined) => Array<FlatArray<A, D>>;
at: (index: number) => CauseReasonIso<E, D> | undefined;
findLast: { (predicate: (value: CauseReasonIso<E, D>, index: number, array: ReadonlyArray<CauseReasonIso<E, D>>) => value is S, thisArg?: any): S | undefined; (predicate: (value: CauseReasonIso<E, D>, index: number, array: ReadonlyArray<CauseReasonI…;
findLastIndex: (predicate: (value: CauseReasonIso<E, D>, index: number, array: ReadonlyArray<CauseReasonIso<E, D>>) => unknown, thisArg?: any) => number;
toReversed: () => Array<CauseReasonIso<E, D>>;
toSorted: (compareFn?: ((a: CauseReasonIso<E, D>, b: CauseReasonIso<E, D>) => number) | undefined) => Array<CauseReasonIso<E, D>>;
toSpliced: { (start: number, deleteCount: number, ...items: Array<CauseReasonIso<E, D>>): Array<CauseReasonIso<E, D>>; (start: number, deleteCount?: number): Array<CauseReasonIso<E, D>> };
with: (index: number, value: CauseReasonIso<E, D>) => Array<CauseReasonIso<E, D>>;
}
cause: type CauseIso<
E extends Constraint,
D extends Constraint
> = readonly CauseReasonIso<E, D>[]
Iso representation used for Cause schemas: an ordered array of
CauseReasonIso values.
When to use
Use when working with the ISO shape of a Cause schema, such as toIso
optics or codecs that expose a cause as its ordered array of encoded reasons.
CauseIso<function (type parameter) E in type ExitIso<A extends Constraint, E extends Constraint, D extends Constraint>E, function (type parameter) D in type ExitIso<A extends Constraint, E extends Constraint, D extends Constraint>D>
}
/**
* Creates a schema for `Exit` values using schemas for the success value, typed
* failure, and unexpected defect channels.
*
* **When to use**
*
* Use when serializing or validating an effect outcome where success, typed
* failure, and defects each need their own schema.
*
* @category Exit
* @since 3.10.0
*/
export function function Exit<
A extends Constraint,
E extends Constraint,
D extends Constraint
>(value: A, error: E, defect: D): Exit<A, E, D>
Creates a schema for Exit values using schemas for the success value, typed
failure, and unexpected defect channels.
When to use
Use when serializing or validating an effect outcome where success, typed
failure, and defects each need their own schema.
Exit<function (type parameter) A in Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>A extends Constraint, function (type parameter) E in Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>E extends Constraint, function (type parameter) D in Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>D extends Constraint>(
value: A extends Constraintvalue: function (type parameter) A in Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>A,
error: E extends Constrainterror: function (type parameter) E in Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>E,
defect: D extends Constraintdefect: function (type parameter) D in Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>D
): interface Exit<A extends Constraint, E extends Constraint, D extends Constraint>Creates a schema for Exit values using schemas for the success value, typed
failure, and unexpected defect channels.
When to use
Use when serializing or validating an effect outcome where success, typed
failure, and defects each need their own schema.
Type-level representation returned by
Exit
.
Exit<function (type parameter) A in Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>A, function (type parameter) E in Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>E, function (type parameter) D in Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>D> {
const const schema: declareConstructor<
Exit_.Exit<A["Type"], E["Type"]>,
Exit_.Exit<A["Encoded"], E["Encoded"]>,
readonly [A, E, D],
ExitIso<A, E, D>
>
const schema: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Annotations.Bottom<Exit_.Exit<A['Type'], E['Type']>, readonly [A, E, D]>) => declareConstructor<Exit_.Exit<A['Type'], E['Type']>, Exit_.Exit<A['Encoded'], E['Encoded']>, readonly [A, E, D], ExitIso<A, E, D>>;
annotateKey: (annotations: Annotations.Key<Exit_.Exit<A['Type'], E['Type']>>) => declareConstructor<Exit_.Exit<A['Type'], E['Type']>, Exit_.Exit<A['Encoded'], E['Encoded']>, readonly [A, E, D], ExitIso<A, E, D>>;
check: (checks_0: SchemaAST.Check<Exit_.Exit<A['Type'], E['Type']>>, ...checks: Array<SchemaAST.Check<Exit_.Exit<A['Type'], E['Type']>>>) => declareConstructor<Exit_.Exit<A['Type'], E['Type']>, Exit_.Exit<A['Encoded'], E['Encoded']>, readonly [A,…;
rebuild: (ast: SchemaAST.Declaration) => declareConstructor<Exit_.Exit<A['Type'], E['Type']>, Exit_.Exit<A['Encoded'], E['Encoded']>, readonly [A, E, D], ExitIso<A, E, D>>;
make: (input: Exit_.Exit<A['Type'], E['Type']>, options?: MakeOptions) => Exit_.Exit<A['Type'], E['Type']>;
makeOption: (input: Exit_.Exit<A['Type'], E['Type']>, options?: MakeOptions) => Option_.Option<Exit_.Exit<A['Type'], E['Type']>>;
makeEffect: (input: Exit_.Exit<A['Type'], E['Type']>, options?: MakeOptions) => Effect.Effect<Exit_.Exit<A['Type'], E['Type']>, SchemaError, never>;
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; <…;
}
schema = function declareConstructor<
T,
E = T,
Iso = T
>(): <
TypeParameters extends ReadonlyArray<Constraint>
>(
typeParameters: TypeParameters,
run: (typeParameters: {
readonly [K in keyof TypeParameters]: Codec<
TypeParameters[K]["Type"],
TypeParameters[K]["Encoded"]
>
}) => (
u: unknown,
self: SchemaAST.Declaration,
options: SchemaAST.ParseOptions
) => Effect.Effect<T, SchemaIssue.Issue>,
annotations?: Annotations.Declaration<
T,
TypeParameters
>
) => declareConstructor<T, E, TypeParameters, Iso>
Creates a schema for a parametric type (a generic container such as
Array<A>, Option<A>, etc.) by accepting a list of type-parameter schemas
and a decoder factory.
When to use
Use when you are defining a schema for a generic container whose validation
depends on one or more type-parameter schemas.
Details
The outer call declareConstructor<T, E, Iso>() fixes the decoded type T,
the encoded type E, and the optional iso type. The inner call receives:
typeParameters — the concrete schemas for each type variable
run — a factory that, given resolved codecs for each type parameter,
returns a parsing function (u, ast, options) => Effect<T, Issue>
annotations — optional metadata
declareConstructor<
import Exit_Exit_.type Exit_.Exit = /*unresolved*/ anyExit<function (type parameter) A in Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>A["Type"], function (type parameter) E in Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>E["Type"]>,
import Exit_Exit_.type Exit_.Exit = /*unresolved*/ anyExit<function (type parameter) A in Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>A["Encoded"], function (type parameter) E in Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>E["Encoded"]>,
type ExitIso<
A extends Constraint,
E extends Constraint,
D extends Constraint
> =
| {
readonly _tag: "Success"
readonly value: A["Iso"]
}
| {
readonly _tag: "Failure"
readonly cause: CauseIso<E, D>
}
Iso representation used for Exit schemas.
Details
Successful exits are represented as { _tag: "Success", value }, while failed
exits are represented as { _tag: "Failure", cause }.
ExitIso<function (type parameter) A in Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>A, function (type parameter) E in Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>E, function (type parameter) D in Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>D>
>()(
[value: A extends Constraintvalue, error: E extends Constrainterror, defect: D extends Constraintdefect],
([value: Codec<
A["Type"],
A["Encoded"],
never,
never
>
(parameter) value: {
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
Rebuild: Codec<T, E, RD, RE>;
Type: T;
Iso: Iso;
ast: Ast;
annotate: (annotations: Annotations.Bottom<A['Type'], any>) => Codec<A['Type'], A['Encoded'], never, never>;
annotateKey: (annotations: Annotations.Key<A['Type']>) => Codec<A['Type'], A['Encoded'], never, never>;
check: (checks_0: SchemaAST.Check<A['Type']>, ...checks: Array<SchemaAST.Check<A['Type']>>) => Codec<A['Type'], A['Encoded'], never, never>;
rebuild: (ast: SchemaAST.AST) => Codec<A['Type'], A['Encoded'], never, never>;
make: (input: unknown, options?: MakeOptions) => A['Type'];
makeOption: (input: unknown, options?: MakeOptions) => Option_.Option<A['Type']>;
makeEffect: (input: unknown, options?: MakeOptions) => Effect.Effect<A['Type'], SchemaError, never>;
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; <…;
}
value, error: Codec<
E["Type"],
E["Encoded"],
never,
never
>
(parameter) error: {
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
Rebuild: Codec<T, E, RD, RE>;
Type: T;
Iso: Iso;
ast: Ast;
annotate: (annotations: Annotations.Bottom<E['Type'], any>) => Codec<E['Type'], E['Encoded'], never, never>;
annotateKey: (annotations: Annotations.Key<E['Type']>) => Codec<E['Type'], E['Encoded'], never, never>;
check: (checks_0: SchemaAST.Check<E['Type']>, ...checks: Array<SchemaAST.Check<E['Type']>>) => Codec<E['Type'], E['Encoded'], never, never>;
rebuild: (ast: SchemaAST.AST) => Codec<E['Type'], E['Encoded'], never, never>;
make: (input: unknown, options?: MakeOptions) => E['Type'];
makeOption: (input: unknown, options?: MakeOptions) => Option_.Option<E['Type']>;
makeEffect: (input: unknown, options?: MakeOptions) => Effect.Effect<E['Type'], SchemaError, never>;
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; <…;
}
error, defect: Codec<
D["Type"],
D["Encoded"],
never,
never
>
(parameter) defect: {
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
Rebuild: Codec<T, E, RD, RE>;
Type: T;
Iso: Iso;
ast: Ast;
annotate: (annotations: Annotations.Bottom<D['Type'], any>) => Codec<D['Type'], D['Encoded'], never, never>;
annotateKey: (annotations: Annotations.Key<D['Type']>) => Codec<D['Type'], D['Encoded'], never, never>;
check: (checks_0: SchemaAST.Check<D['Type']>, ...checks: Array<SchemaAST.Check<D['Type']>>) => Codec<D['Type'], D['Encoded'], never, never>;
rebuild: (ast: SchemaAST.AST) => Codec<D['Type'], D['Encoded'], never, never>;
make: (input: unknown, options?: MakeOptions) => D['Type'];
makeOption: (input: unknown, options?: MakeOptions) => Option_.Option<D['Type']>;
makeEffect: (input: unknown, options?: MakeOptions) => Effect.Effect<D['Type'], SchemaError, never>;
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; <…;
}
defect]) => {
const const cause: Cause<
Codec<E["Type"], E["Encoded"], never, never>,
Codec<D["Type"], D["Encoded"], never, never>
>
const cause: {
Rebuild: Cause<E, D>;
error: E;
defect: D;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Annotations.Bottom<Cause_.Cause<E['Type']>, readonly [Codec<E['Type'], E['Encoded'], never, never>, Codec<D['Type'], D['Encoded'], never, never>]>) => Cause<Codec<E['Type'], E['Encoded'], never, never>, Codec<D['Type'], D['En…;
annotateKey: (annotations: Annotations.Key<Cause_.Cause<E['Type']>>) => Cause<Codec<E['Type'], E['Encoded'], never, never>, Codec<D['Type'], D['Encoded'], never, never>>;
check: (checks_0: SchemaAST.Check<Cause_.Cause<E['Type']>>, ...checks: Array<SchemaAST.Check<Cause_.Cause<E['Type']>>>) => Cause<Codec<E['Type'], E['Encoded'], never, never>, Codec<D['Type'], D['Encoded'], never, never>>;
rebuild: (ast: SchemaAST.Declaration) => Cause<Codec<E['Type'], E['Encoded'], never, never>, Codec<D['Type'], D['Encoded'], never, never>>;
make: (input: Cause_.Cause<E['Type']>, options?: MakeOptions) => Cause_.Cause<E['Type']>;
makeOption: (input: Cause_.Cause<E['Type']>, options?: MakeOptions) => Option_.Option<Cause_.Cause<E['Type']>>;
makeEffect: (input: Cause_.Cause<E['Type']>, options?: MakeOptions) => Effect.Effect<Cause_.Cause<E['Type']>, SchemaError, never>;
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; <…;
}
cause = function Cause<
E extends Constraint,
D extends Constraint
>(error: E, defect: D): Cause<E, D>
Creates a schema for Cause values using separate schemas for typed failures
and unexpected defects.
When to use
Use to validate, transform, or serialize Effect failure causes when typed
failures and unexpected defects need separate schemas.
Details
The error schema is applied to Fail reasons and the defect schema is
applied to Die reasons. Interrupt reasons do not use either schema and
carry only an optional fiber id.
Cause(error: Codec<
E["Type"],
E["Encoded"],
never,
never
>
(parameter) error: {
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
Rebuild: Codec<T, E, RD, RE>;
Type: T;
Iso: Iso;
ast: Ast;
annotate: (annotations: Annotations.Bottom<E['Type'], any>) => Codec<E['Type'], E['Encoded'], never, never>;
annotateKey: (annotations: Annotations.Key<E['Type']>) => Codec<E['Type'], E['Encoded'], never, never>;
check: (checks_0: SchemaAST.Check<E['Type']>, ...checks: Array<SchemaAST.Check<E['Type']>>) => Codec<E['Type'], E['Encoded'], never, never>;
rebuild: (ast: SchemaAST.AST) => Codec<E['Type'], E['Encoded'], never, never>;
make: (input: unknown, options?: MakeOptions) => E['Type'];
makeOption: (input: unknown, options?: MakeOptions) => Option_.Option<E['Type']>;
makeEffect: (input: unknown, options?: MakeOptions) => Effect.Effect<E['Type'], SchemaError, never>;
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; <…;
}
error, defect: Codec<
D["Type"],
D["Encoded"],
never,
never
>
(parameter) defect: {
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
Rebuild: Codec<T, E, RD, RE>;
Type: T;
Iso: Iso;
ast: Ast;
annotate: (annotations: Annotations.Bottom<D['Type'], any>) => Codec<D['Type'], D['Encoded'], never, never>;
annotateKey: (annotations: Annotations.Key<D['Type']>) => Codec<D['Type'], D['Encoded'], never, never>;
check: (checks_0: SchemaAST.Check<D['Type']>, ...checks: Array<SchemaAST.Check<D['Type']>>) => Codec<D['Type'], D['Encoded'], never, never>;
rebuild: (ast: SchemaAST.AST) => Codec<D['Type'], D['Encoded'], never, never>;
make: (input: unknown, options?: MakeOptions) => D['Type'];
makeOption: (input: unknown, options?: MakeOptions) => Option_.Option<D['Type']>;
makeEffect: (input: unknown, options?: MakeOptions) => Effect.Effect<D['Type'], SchemaError, never>;
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; <…;
}
defect)
return (input: unknowninput, ast: SchemaAST.Declaration(parameter) ast: {
_tag: 'Declaration';
typeParameters: ReadonlyArray<AST>;
run: (typeParameters: ReadonlyArray<AST>) => (input: unknown, self: Declaration, options: ParseOptions) => Effect.Effect<any, SchemaIssue.Issue, any>;
encodingChecks: Checks | undefined;
getParser: () => SchemaParser.Parser;
_rebuild: (recur: (ast: AST) => AST, checks: Checks | undefined, encodingChecks: Checks | undefined) => Declaration;
recur: (recur: (ast: AST) => AST) => Declaration;
flip: (recur: (ast: AST) => AST) => Declaration;
getExpected: () => string;
annotations: Schema.Annotations.Annotations | undefined;
checks: Checks | undefined;
encoding: Encoding | undefined;
context: Context | undefined;
toString: () => string;
}
ast, options: SchemaAST.ParseOptions(parameter) options: {
errors: "first" | "all" | undefined;
onExcessProperty: "ignore" | "error" | "preserve" | undefined;
propertyOrder: "none" | "original" | undefined;
disableChecks: boolean | undefined;
concurrency: number | "unbounded" | undefined;
}
options) => {
if (!import Exit_Exit_.isExit(input: unknowninput)) {
return import EffectEffect.fail(new import SchemaIssueSchemaIssue.constructor InvalidType(ast: SchemaAST.AST, actual: StandardJSONSchemaV1<unknown>): SchemaIssue.InvalidTypeRepresents a schema issue produced when the runtime type of the input does not match the type
expected by the schema (e.g. got null when string was expected).
When to use
Use when you need to detect basic type mismatches, such as a wrong primitive
or null where an object was expected.
Details
ast is the schema node that expected a different type.
actual is Option.some(value) when the input was present, or
Option.none() when no value was provided.
- The default formatter renders this as
"Expected <type>, got <actual>".
Example (Formatting output)
import { Schema } from "effect"
try {
Schema.decodeUnknownSync(Schema.String)(42)
} catch (e) {
if (Schema.isSchemaError(e)) {
console.log(String(e.issue))
// "Expected string, got 42"
}
}
InvalidType(ast: SchemaAST.Declaration(parameter) ast: {
_tag: 'Declaration';
typeParameters: ReadonlyArray<AST>;
run: (typeParameters: ReadonlyArray<AST>) => (input: unknown, self: Declaration, options: ParseOptions) => Effect.Effect<any, SchemaIssue.Issue, any>;
encodingChecks: Checks | undefined;
getParser: () => SchemaParser.Parser;
_rebuild: (recur: (ast: AST) => AST, checks: Checks | undefined, encodingChecks: Checks | undefined) => Declaration;
recur: (recur: (ast: AST) => AST) => Declaration;
flip: (recur: (ast: AST) => AST) => Declaration;
getExpected: () => string;
annotations: Schema.Annotations.Annotations | undefined;
checks: Checks | undefined;
encoding: Encoding | undefined;
context: Context | undefined;
toString: () => string;
}
ast, import Option_Option_.some(input: unknowninput)))
}
switch (input: Exit_.Exit<unknown, unknown>input._tag) {
case "Success":
return import EffectEffect.mapBothEager(
import SchemaParserSchemaParser.function decodeUnknownEffect<
S extends Schema.Constraint
>(
schema: S,
options?: SchemaAST.ParseOptions
): (
input: unknown,
options?: SchemaAST.ParseOptions
) => Effect.Effect<
S["Type"],
SchemaIssue.Issue,
S["DecodingServices"]
>
Creates an effectful decoder for unknown input.
When to use
Use when you need to decode untyped boundary input in an Effect whose
failure channel is SchemaIssue.Issue, while preserving transformations
and service requirements.
Details
The returned function succeeds with the schema's decoded Type or fails with a
SchemaIssue.Issue. Decoding service requirements are preserved in the returned
Effect. Parse options may be provided when creating the decoder and overridden
when applying it.
decodeUnknownEffect(value: Codec<
A["Type"],
A["Encoded"],
never,
never
>
(parameter) value: {
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
Rebuild: Codec<T, E, RD, RE>;
Type: T;
Iso: Iso;
ast: Ast;
annotate: (annotations: Annotations.Bottom<A['Type'], any>) => Codec<A['Type'], A['Encoded'], never, never>;
annotateKey: (annotations: Annotations.Key<A['Type']>) => Codec<A['Type'], A['Encoded'], never, never>;
check: (checks_0: SchemaAST.Check<A['Type']>, ...checks: Array<SchemaAST.Check<A['Type']>>) => Codec<A['Type'], A['Encoded'], never, never>;
rebuild: (ast: SchemaAST.AST) => Codec<A['Type'], A['Encoded'], never, never>;
make: (input: unknown, options?: MakeOptions) => A['Type'];
makeOption: (input: unknown, options?: MakeOptions) => Option_.Option<A['Type']>;
makeEffect: (input: unknown, options?: MakeOptions) => Effect.Effect<A['Type'], SchemaError, never>;
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; <…;
}
value)(input: Exit_.Success<unknown, unknown>(parameter) input: {
_tag: "Success";
value: A;
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;
}
input.value, options: SchemaAST.ParseOptions(parameter) options: {
errors: "first" | "all" | undefined;
onExcessProperty: "ignore" | "error" | "preserve" | undefined;
propertyOrder: "none" | "original" | undefined;
disableChecks: boolean | undefined;
concurrency: number | "unbounded" | undefined;
}
options),
{
onSuccess: <A>(a: A) => Exit<A>onSuccess: import Exit_Exit_.succeed,
onFailure: (issue: any) => SchemaIssue.CompositeonFailure: (issue: SchemaIssue.Issueissue) =>
new import SchemaIssueSchemaIssue.constructor Composite(ast: SchemaAST.AST, actual: StandardJSONSchemaV1<unknown>, issues: readonly [SchemaIssue.Issue, ...Array<SchemaIssue.Issue>]): SchemaIssue.CompositeRepresents a schema issue that groups multiple child issues under a single schema node.
When to use
Use when you need to walk the issue tree for struct/tuple schemas that collect
all field errors rather than failing on the first.
Details
issues is a non-empty readonly array (at least one child).
actual is Option.some(value) when the input was present, or
Option.none() when absent.
- Formatters flatten
Composite by recursing into each child.
Composite(ast: SchemaAST.Declaration(parameter) ast: {
_tag: 'Declaration';
typeParameters: ReadonlyArray<AST>;
run: (typeParameters: ReadonlyArray<AST>) => (input: unknown, self: Declaration, options: ParseOptions) => Effect.Effect<any, SchemaIssue.Issue, any>;
encodingChecks: Checks | undefined;
getParser: () => SchemaParser.Parser;
_rebuild: (recur: (ast: AST) => AST, checks: Checks | undefined, encodingChecks: Checks | undefined) => Declaration;
recur: (recur: (ast: AST) => AST) => Declaration;
flip: (recur: (ast: AST) => AST) => Declaration;
getExpected: () => string;
annotations: Schema.Annotations.Annotations | undefined;
checks: Checks | undefined;
encoding: Encoding | undefined;
context: Context | undefined;
toString: () => string;
}
ast, import Option_Option_.some(input: Exit_.Success<unknown, unknown>(parameter) input: {
_tag: "Success";
value: A;
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;
}
input), [new import SchemaIssueSchemaIssue.constructor Pointer(path: ReadonlyArray<PropertyKey>, issue: SchemaIssue.Issue): SchemaIssue.PointerWraps an inner
Issue
with a property-key path, indicating where in
a nested structure the error occurred.
When to use
Use when you need to walk the issue tree to accumulate path segments for error
reporting.
Details
path is an array of property keys (strings, numbers, or symbols).
- Has no
actual value —
getActual
returns Option.none().
- Formatters concatenate nested
Pointer paths into a single path like
["a"]["b"][0].
Pointer(["value"], issue: SchemaIssue.Issueissue)])
}
)
case "Failure":
return import EffectEffect.mapBothEager(
import SchemaParserSchemaParser.function decodeUnknownEffect<
S extends Schema.Constraint
>(
schema: S,
options?: SchemaAST.ParseOptions
): (
input: unknown,
options?: SchemaAST.ParseOptions
) => Effect.Effect<
S["Type"],
SchemaIssue.Issue,
S["DecodingServices"]
>
Creates an effectful decoder for unknown input.
When to use
Use when you need to decode untyped boundary input in an Effect whose
failure channel is SchemaIssue.Issue, while preserving transformations
and service requirements.
Details
The returned function succeeds with the schema's decoded Type or fails with a
SchemaIssue.Issue. Decoding service requirements are preserved in the returned
Effect. Parse options may be provided when creating the decoder and overridden
when applying it.
decodeUnknownEffect(const cause: Cause<
Codec<E["Type"], E["Encoded"], never, never>,
Codec<D["Type"], D["Encoded"], never, never>
>
const cause: {
Rebuild: Cause<E, D>;
error: E;
defect: D;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Annotations.Bottom<Cause_.Cause<E['Type']>, readonly [Codec<E['Type'], E['Encoded'], never, never>, Codec<D['Type'], D['Encoded'], never, never>]>) => Cause<Codec<E['Type'], E['Encoded'], never, never>, Codec<D['Type'], D['En…;
annotateKey: (annotations: Annotations.Key<Cause_.Cause<E['Type']>>) => Cause<Codec<E['Type'], E['Encoded'], never, never>, Codec<D['Type'], D['Encoded'], never, never>>;
check: (checks_0: SchemaAST.Check<Cause_.Cause<E['Type']>>, ...checks: Array<SchemaAST.Check<Cause_.Cause<E['Type']>>>) => Cause<Codec<E['Type'], E['Encoded'], never, never>, Codec<D['Type'], D['Encoded'], never, never>>;
rebuild: (ast: SchemaAST.Declaration) => Cause<Codec<E['Type'], E['Encoded'], never, never>, Codec<D['Type'], D['Encoded'], never, never>>;
make: (input: Cause_.Cause<E['Type']>, options?: MakeOptions) => Cause_.Cause<E['Type']>;
makeOption: (input: Cause_.Cause<E['Type']>, options?: MakeOptions) => Option_.Option<Cause_.Cause<E['Type']>>;
makeEffect: (input: Cause_.Cause<E['Type']>, options?: MakeOptions) => Effect.Effect<Cause_.Cause<E['Type']>, SchemaError, never>;
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; <…;
}
cause)(input: Exit_.Failure<unknown, unknown>(parameter) input: {
_tag: "Failure";
cause: Cause.Cause<E>;
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;
}
input.cause, options: SchemaAST.ParseOptions(parameter) options: {
errors: "first" | "all" | undefined;
onExcessProperty: "ignore" | "error" | "preserve" | undefined;
propertyOrder: "none" | "original" | undefined;
disableChecks: boolean | undefined;
concurrency: number | "unbounded" | undefined;
}
options),
{
onSuccess: <E>(
cause: Cause.Cause<E>
) => Exit<never, E>
onSuccess: import Exit_Exit_.failCause,
onFailure: (issue: any) => SchemaIssue.CompositeonFailure: (issue: SchemaIssue.Issueissue) =>
new import SchemaIssueSchemaIssue.constructor Composite(ast: SchemaAST.AST, actual: StandardJSONSchemaV1<unknown>, issues: readonly [SchemaIssue.Issue, ...Array<SchemaIssue.Issue>]): SchemaIssue.CompositeRepresents a schema issue that groups multiple child issues under a single schema node.
When to use
Use when you need to walk the issue tree for struct/tuple schemas that collect
all field errors rather than failing on the first.
Details
issues is a non-empty readonly array (at least one child).
actual is Option.some(value) when the input was present, or
Option.none() when absent.
- Formatters flatten
Composite by recursing into each child.
Composite(ast: SchemaAST.Declaration(parameter) ast: {
_tag: 'Declaration';
typeParameters: ReadonlyArray<AST>;
run: (typeParameters: ReadonlyArray<AST>) => (input: unknown, self: Declaration, options: ParseOptions) => Effect.Effect<any, SchemaIssue.Issue, any>;
encodingChecks: Checks | undefined;
getParser: () => SchemaParser.Parser;
_rebuild: (recur: (ast: AST) => AST, checks: Checks | undefined, encodingChecks: Checks | undefined) => Declaration;
recur: (recur: (ast: AST) => AST) => Declaration;
flip: (recur: (ast: AST) => AST) => Declaration;
getExpected: () => string;
annotations: Schema.Annotations.Annotations | undefined;
checks: Checks | undefined;
encoding: Encoding | undefined;
context: Context | undefined;
toString: () => string;
}
ast, import Option_Option_.some(input: Exit_.Failure<unknown, unknown>(parameter) input: {
_tag: "Failure";
cause: Cause.Cause<E>;
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;
}
input), [new import SchemaIssueSchemaIssue.constructor Pointer(path: ReadonlyArray<PropertyKey>, issue: SchemaIssue.Issue): SchemaIssue.PointerWraps an inner
Issue
with a property-key path, indicating where in
a nested structure the error occurred.
When to use
Use when you need to walk the issue tree to accumulate path segments for error
reporting.
Details
path is an array of property keys (strings, numbers, or symbols).
- Has no
actual value —
getActual
returns Option.none().
- Formatters concatenate nested
Pointer paths into a single path like
["a"]["b"][0].
Pointer(["cause"], issue: SchemaIssue.Issueissue)])
}
)
}
}
},
{
Annotations.Declaration<Exit_.Exit<A["Type"], E["Type"]>, readonly [A, E, D]>.typeConstructor?: {
readonly [key: string]: unknown;
readonly _tag: string;
} | undefined
typeConstructor: {
_tag: string_tag: "effect/Exit"
},
Annotations.Declaration<Exit_.Exit<A["Type"], E["Type"]>, readonly [A, E, D]>.generation?: {
readonly runtime: string;
readonly Type: string;
readonly Encoded?: string | undefined;
readonly importDeclaration?: string | undefined;
} | undefined
generation: {
runtime: stringruntime: `Schema.Exit(?, ?, ?)`,
type Type: stringType: `Exit.Exit<?, ?, ?>`,
importDeclaration?: string | undefinedimportDeclaration: `import * as Exit from "effect/Exit"`
},
Annotations.Augment.expected?: string | undefinedHuman-readable description of what a value is expected to satisfy.
Details
For filter and refinement failures, the default formatter uses
message first, then expected, and finally falls back to <filter>.
Use this to name a failed filter in the default message:
Expected <expected>, got <actual>.
expected: "Exit",
Annotations.Declaration<Exit_.Exit<A["Type"], E["Type"]>, readonly [A, E, D]>.toCodec?: ((typeParameters: readonly [Codec<A["Encoded"], A["Encoded"], never, never>, Codec<E["Encoded"], E["Encoded"], never, never>, Codec<D["Encoded"], D["Encoded"], never, never>]) => SchemaAST.Link) | undefinedtoCodec: ([value: Codec<
A["Encoded"],
A["Encoded"],
never,
never
>
(parameter) value: {
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
Rebuild: Codec<T, E, RD, RE>;
Type: T;
Iso: Iso;
ast: Ast;
annotate: (annotations: Annotations.Bottom<A['Encoded'], any>) => Codec<A['Encoded'], A['Encoded'], never, never>;
annotateKey: (annotations: Annotations.Key<A['Encoded']>) => Codec<A['Encoded'], A['Encoded'], never, never>;
check: (checks_0: SchemaAST.Check<A['Encoded']>, ...checks: Array<SchemaAST.Check<A['Encoded']>>) => Codec<A['Encoded'], A['Encoded'], never, never>;
rebuild: (ast: SchemaAST.AST) => Codec<A['Encoded'], A['Encoded'], never, never>;
make: (input: unknown, options?: MakeOptions) => A['Encoded'];
makeOption: (input: unknown, options?: MakeOptions) => Option_.Option<A['Encoded']>;
makeEffect: (input: unknown, options?: MakeOptions) => Effect.Effect<A['Encoded'], SchemaError, never>;
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; <…;
}
value, error: Codec<
E["Encoded"],
E["Encoded"],
never,
never
>
(parameter) error: {
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
Rebuild: Codec<T, E, RD, RE>;
Type: T;
Iso: Iso;
ast: Ast;
annotate: (annotations: Annotations.Bottom<E['Encoded'], any>) => Codec<E['Encoded'], E['Encoded'], never, never>;
annotateKey: (annotations: Annotations.Key<E['Encoded']>) => Codec<E['Encoded'], E['Encoded'], never, never>;
check: (checks_0: SchemaAST.Check<E['Encoded']>, ...checks: Array<SchemaAST.Check<E['Encoded']>>) => Codec<E['Encoded'], E['Encoded'], never, never>;
rebuild: (ast: SchemaAST.AST) => Codec<E['Encoded'], E['Encoded'], never, never>;
make: (input: unknown, options?: MakeOptions) => E['Encoded'];
makeOption: (input: unknown, options?: MakeOptions) => Option_.Option<E['Encoded']>;
makeEffect: (input: unknown, options?: MakeOptions) => Effect.Effect<E['Encoded'], SchemaError, never>;
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; <…;
}
error, defect: Codec<
D["Encoded"],
D["Encoded"],
never,
never
>
(parameter) defect: {
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
Rebuild: Codec<T, E, RD, RE>;
Type: T;
Iso: Iso;
ast: Ast;
annotate: (annotations: Annotations.Bottom<D['Encoded'], any>) => Codec<D['Encoded'], D['Encoded'], never, never>;
annotateKey: (annotations: Annotations.Key<D['Encoded']>) => Codec<D['Encoded'], D['Encoded'], never, never>;
check: (checks_0: SchemaAST.Check<D['Encoded']>, ...checks: Array<SchemaAST.Check<D['Encoded']>>) => Codec<D['Encoded'], D['Encoded'], never, never>;
rebuild: (ast: SchemaAST.AST) => Codec<D['Encoded'], D['Encoded'], never, never>;
make: (input: unknown, options?: MakeOptions) => D['Encoded'];
makeOption: (input: unknown, options?: MakeOptions) => Option_.Option<D['Encoded']>;
makeEffect: (input: unknown, options?: MakeOptions) => Effect.Effect<D['Encoded'], SchemaError, never>;
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; <…;
}
defect]) =>
function link<T>(): <
To extends Constraint
>(
encodeTo: To,
transformation: {
readonly decode: SchemaGetter.Getter<
T,
NoInfer<To["Type"]>
>
readonly encode: SchemaGetter.Getter<
NoInfer<To["Type"]>,
T
>
}
) => SchemaAST.Link
Constructs an SchemaAST.Link that describes how a value of type T encodes to and decodes from a To schema.
Used when building low-level AST transformations that bridge two schema types.
link<import Exit_Exit_.type Exit_.Exit = /*unresolved*/ anyExit<function (type parameter) A in Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>A["Encoded"], function (type parameter) E in Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>E["Encoded"]>>()(
function Union<
Members extends ReadonlyArray<Constraint>
>(
members: Members,
options?: { mode?: "anyOf" | "oneOf" }
): Union<Members>
Creates a union schema from an array of member schemas. Members are tested in
order; the first match is returned.
Details
Optionally, specify mode:
"anyOf" (default) — matches if any member matches.
"oneOf" — matches if exactly one member matches.
Example (Defining a string or number union)
import { Schema } from "effect"
const schema = Schema.Union([Schema.String, Schema.Number])
Schema.decodeUnknownSync(schema)("hello") // "hello"
Schema.decodeUnknownSync(schema)(42) // 42
Union([
function Struct<
Fields extends Struct.Fields
>(fields: Fields): Struct<Fields>
Defines a struct schema from a map of field schemas.
Details
Each field value is a schema. Use
optionalKey
or
optional
to
mark fields as optional, and
mutableKey
to mark them as mutable.
The resulting schema's Type is a readonly object type with the fields'
decoded types. The Encoded form mirrors the field schemas' encoded types.
Example (Defining a basic struct)
import { Schema } from "effect"
const Person = Schema.Struct({
name: Schema.String,
age: Schema.Number,
email: Schema.optionalKey(Schema.String)
})
// { readonly name: string; readonly age: number; readonly email?: string }
type Person = typeof Person.Type
const alice = Schema.decodeUnknownSync(Person)({ name: "Alice", age: 30 })
console.log(alice)
// { name: 'Alice', age: 30 }
Struct({ _tag: Literal<"Success">(property) _tag: {
literal: L;
transform: (to: L2) => decodeTo<Literal<L2>, Literal<'Success'>, never, never>;
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Annotations.Bottom<'Success', readonly []>) => Literal<'Success'>;
annotateKey: (annotations: Annotations.Key<'Success'>) => Literal<'Success'>;
check: (checks_0: SchemaAST.Check<'Success'>, ...checks: Array<SchemaAST.Check<'Success'>>) => Literal<'Success'>;
rebuild: (ast: SchemaAST.Literal) => Literal<'Success'>;
make: (input: 'Success', options?: MakeOptions) => 'Success';
makeOption: (input: 'Success', options?: MakeOptions) => Option_.Option<'Success'>;
makeEffect: (input: 'Success', options?: MakeOptions) => Effect.Effect<'Success', SchemaError, never>;
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; <…;
}
_tag: function Literal<
L extends SchemaAST.LiteralValue
>(literal: L): Literal<L>
Creates a schema for a single literal value (string, number, bigint, boolean, or null).
Example (Defining a string literal)
import { Schema } from "effect"
const schema = Schema.Literal("hello")
// Type: Schema.Literal<"hello">
Literal("Success"), value: Codec<
A["Encoded"],
A["Encoded"],
never,
never
>
(property) value: {
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
Rebuild: Codec<T, E, RD, RE>;
Type: T;
Iso: Iso;
ast: Ast;
annotate: (annotations: Annotations.Bottom<A['Encoded'], any>) => Codec<A['Encoded'], A['Encoded'], never, never>;
annotateKey: (annotations: Annotations.Key<A['Encoded']>) => Codec<A['Encoded'], A['Encoded'], never, never>;
check: (checks_0: SchemaAST.Check<A['Encoded']>, ...checks: Array<SchemaAST.Check<A['Encoded']>>) => Codec<A['Encoded'], A['Encoded'], never, never>;
rebuild: (ast: SchemaAST.AST) => Codec<A['Encoded'], A['Encoded'], never, never>;
make: (input: unknown, options?: MakeOptions) => A['Encoded'];
makeOption: (input: unknown, options?: MakeOptions) => Option_.Option<A['Encoded']>;
makeEffect: (input: unknown, options?: MakeOptions) => Effect.Effect<A['Encoded'], SchemaError, never>;
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; <…;
}
value }),
function Struct<
Fields extends Struct.Fields
>(fields: Fields): Struct<Fields>
Defines a struct schema from a map of field schemas.
Details
Each field value is a schema. Use
optionalKey
or
optional
to
mark fields as optional, and
mutableKey
to mark them as mutable.
The resulting schema's Type is a readonly object type with the fields'
decoded types. The Encoded form mirrors the field schemas' encoded types.
Example (Defining a basic struct)
import { Schema } from "effect"
const Person = Schema.Struct({
name: Schema.String,
age: Schema.Number,
email: Schema.optionalKey(Schema.String)
})
// { readonly name: string; readonly age: number; readonly email?: string }
type Person = typeof Person.Type
const alice = Schema.decodeUnknownSync(Person)({ name: "Alice", age: 30 })
console.log(alice)
// { name: 'Alice', age: 30 }
Struct({ _tag: Literal<"Failure">(property) _tag: {
literal: L;
transform: (to: L2) => decodeTo<Literal<L2>, Literal<'Failure'>, never, never>;
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Annotations.Bottom<'Failure', readonly []>) => Literal<'Failure'>;
annotateKey: (annotations: Annotations.Key<'Failure'>) => Literal<'Failure'>;
check: (checks_0: SchemaAST.Check<'Failure'>, ...checks: Array<SchemaAST.Check<'Failure'>>) => Literal<'Failure'>;
rebuild: (ast: SchemaAST.Literal) => Literal<'Failure'>;
make: (input: 'Failure', options?: MakeOptions) => 'Failure';
makeOption: (input: 'Failure', options?: MakeOptions) => Option_.Option<'Failure'>;
makeEffect: (input: 'Failure', options?: MakeOptions) => Effect.Effect<'Failure', SchemaError, never>;
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; <…;
}
_tag: function Literal<
L extends SchemaAST.LiteralValue
>(literal: L): Literal<L>
Creates a schema for a single literal value (string, number, bigint, boolean, or null).
Example (Defining a string literal)
import { Schema } from "effect"
const schema = Schema.Literal("hello")
// Type: Schema.Literal<"hello">
Literal("Failure"), cause: Cause<
Codec<E["Encoded"], E["Encoded"], never, never>,
Codec<D["Encoded"], D["Encoded"], never, never>
>
(property) cause: {
Rebuild: Cause<E, D>;
error: E;
defect: D;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Annotations.Bottom<Cause_.Cause<E['Encoded']>, readonly [Codec<E['Encoded'], E['Encoded'], never, never>, Codec<D['Encoded'], D['Encoded'], never, never>]>) => Cause<Codec<E['Encoded'], E['Encoded'], never, never>, Codec<D['E…;
annotateKey: (annotations: Annotations.Key<Cause_.Cause<E['Encoded']>>) => Cause<Codec<E['Encoded'], E['Encoded'], never, never>, Codec<D['Encoded'], D['Encoded'], never, never>>;
check: (checks_0: SchemaAST.Check<Cause_.Cause<E['Encoded']>>, ...checks: Array<SchemaAST.Check<Cause_.Cause<E['Encoded']>>>) => Cause<Codec<E['Encoded'], E['Encoded'], never, never>, Codec<D['Encoded'], D['Encoded'], never, never>>;
rebuild: (ast: SchemaAST.Declaration) => Cause<Codec<E['Encoded'], E['Encoded'], never, never>, Codec<D['Encoded'], D['Encoded'], never, never>>;
make: (input: Cause_.Cause<E['Encoded']>, options?: MakeOptions) => Cause_.Cause<E['Encoded']>;
makeOption: (input: Cause_.Cause<E['Encoded']>, options?: MakeOptions) => Option_.Option<Cause_.Cause<E['Encoded']>>;
makeEffect: (input: Cause_.Cause<E['Encoded']>, options?: MakeOptions) => Effect.Effect<Cause_.Cause<E['Encoded']>, SchemaError, never>;
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; <…;
}
cause: function Cause<
E extends Constraint,
D extends Constraint
>(error: E, defect: D): Cause<E, D>
Creates a schema for Cause values using separate schemas for typed failures
and unexpected defects.
When to use
Use to validate, transform, or serialize Effect failure causes when typed
failures and unexpected defects need separate schemas.
Details
The error schema is applied to Fail reasons and the defect schema is
applied to Die reasons. Interrupt reasons do not use either schema and
carry only an optional fiber id.
Cause(error: Codec<
E["Encoded"],
E["Encoded"],
never,
never
>
(parameter) error: {
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
Rebuild: Codec<T, E, RD, RE>;
Type: T;
Iso: Iso;
ast: Ast;
annotate: (annotations: Annotations.Bottom<E['Encoded'], any>) => Codec<E['Encoded'], E['Encoded'], never, never>;
annotateKey: (annotations: Annotations.Key<E['Encoded']>) => Codec<E['Encoded'], E['Encoded'], never, never>;
check: (checks_0: SchemaAST.Check<E['Encoded']>, ...checks: Array<SchemaAST.Check<E['Encoded']>>) => Codec<E['Encoded'], E['Encoded'], never, never>;
rebuild: (ast: SchemaAST.AST) => Codec<E['Encoded'], E['Encoded'], never, never>;
make: (input: unknown, options?: MakeOptions) => E['Encoded'];
makeOption: (input: unknown, options?: MakeOptions) => Option_.Option<E['Encoded']>;
makeEffect: (input: unknown, options?: MakeOptions) => Effect.Effect<E['Encoded'], SchemaError, never>;
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; <…;
}
error, defect: Codec<
D["Encoded"],
D["Encoded"],
never,
never
>
(parameter) defect: {
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
Rebuild: Codec<T, E, RD, RE>;
Type: T;
Iso: Iso;
ast: Ast;
annotate: (annotations: Annotations.Bottom<D['Encoded'], any>) => Codec<D['Encoded'], D['Encoded'], never, never>;
annotateKey: (annotations: Annotations.Key<D['Encoded']>) => Codec<D['Encoded'], D['Encoded'], never, never>;
check: (checks_0: SchemaAST.Check<D['Encoded']>, ...checks: Array<SchemaAST.Check<D['Encoded']>>) => Codec<D['Encoded'], D['Encoded'], never, never>;
rebuild: (ast: SchemaAST.AST) => Codec<D['Encoded'], D['Encoded'], never, never>;
make: (input: unknown, options?: MakeOptions) => D['Encoded'];
makeOption: (input: unknown, options?: MakeOptions) => Option_.Option<D['Encoded']>;
makeEffect: (input: unknown, options?: MakeOptions) => Effect.Effect<D['Encoded'], SchemaError, never>;
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; <…;
}
defect) })
]),
import SchemaTransformationSchemaTransformation.function transform<T, E>(options: {
readonly decode: (input: E) => T
readonly encode: (input: T) => E
}): Transformation<T, E>
Creates a Transformation from pure (sync, infallible) decode and encode
functions.
When to use
Use when you need an infallible schema transformation that does not require
Effect services.
Details
- Each function receives the input and returns the output directly.
- Skips
None inputs (missing keys) — functions are only called on present values.
- Does not allocate Effects internally; uses optimized sync path.
Example (Converting between cents and dollars)
import { Schema, SchemaTransformation } from "effect"
const CentsFromDollars = Schema.Number.pipe(
Schema.decodeTo(
Schema.Number,
SchemaTransformation.transform({
decode: (dollars) => dollars * 100,
encode: (cents) => cents / 100
})
)
)
transform({
decode: (
e: NoInfer<
| Struct.ReadonlySide<
{
readonly _tag: Literal<"Success">
readonly value: Codec<
A["Encoded"],
A["Encoded"],
never,
never
>
},
"Type"
>
| Struct.ReadonlySide<
{
readonly _tag: Literal<"Failure">
readonly cause: Cause<
Codec<
E["Encoded"],
E["Encoded"],
never,
never
>,
Codec<
D["Encoded"],
D["Encoded"],
never,
never
>
>
},
"Type"
>
>
) => Exit_.Exit<A["Encoded"], E["Encoded"]>
decode: (e: NoInfer<
| Struct.ReadonlySide<
{
readonly _tag: Literal<"Success">
readonly value: Codec<
A["Encoded"],
A["Encoded"],
never,
never
>
},
"Type"
>
| Struct.ReadonlySide<
{
readonly _tag: Literal<"Failure">
readonly cause: Cause<
Codec<
E["Encoded"],
E["Encoded"],
never,
never
>,
Codec<
D["Encoded"],
D["Encoded"],
never,
never
>
>
},
"Type"
>
>
e): import Exit_Exit_.type Exit_.Exit = /*unresolved*/ anyExit<function (type parameter) A in Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>A["Encoded"], function (type parameter) E in Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>E["Encoded"]> =>
e: | Struct.ReadonlySide<
{
readonly _tag: Literal<"Success">
readonly value: Codec<
A["Encoded"],
A["Encoded"],
never,
never
>
},
"Type"
>
| Struct.ReadonlySide<
{
readonly _tag: Literal<"Failure">
readonly cause: Cause<
Codec<
E["Encoded"],
E["Encoded"],
never,
never
>,
Codec<
D["Encoded"],
D["Encoded"],
never,
never
>
>
},
"Type"
>
e._tag: "Success" | "Failure"_tag === "Success" ? import Exit_Exit_.succeed(e: Struct.ReadonlySide<
{
readonly _tag: Literal<"Success">
readonly value: Codec<
A["Encoded"],
A["Encoded"],
never,
never
>
},
"Type"
>
(parameter) e: {
_tag: 'Success';
value: A['Encoded'];
}
e.value: A["Encoded"]value) : import Exit_Exit_.failCause(e: Struct.ReadonlySide<
{
readonly _tag: Literal<"Failure">
readonly cause: Cause<
Codec<
E["Encoded"],
E["Encoded"],
never,
never
>,
Codec<
D["Encoded"],
D["Encoded"],
never,
never
>
>
},
"Type"
>
(parameter) e: {
_tag: 'Failure';
cause: Cause_.Cause<E['Encoded']>;
}
e.cause: Cause_.Cause<E["Encoded"]>(property) cause: {
reasons: ReadonlyArray<Reason<E>>;
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;
}
cause),
encode: (
input: Exit_.Exit<A["Encoded"], E["Encoded"]>
) => NoInfer<
| Struct.ReadonlySide<
{
readonly _tag: Literal<"Success">
readonly value: Codec<
A["Encoded"],
A["Encoded"],
never,
never
>
},
"Type"
>
| Struct.ReadonlySide<
{
readonly _tag: Literal<"Failure">
readonly cause: Cause<
Codec<
E["Encoded"],
E["Encoded"],
never,
never
>,
Codec<
D["Encoded"],
D["Encoded"],
never,
never
>
>
},
"Type"
>
>
encode: (exit: Exit_.Exit<A["Encoded"], E["Encoded"]>exit) =>
import Exit_Exit_.isSuccess(exit: Exit_.Exit<A["Encoded"], E["Encoded"]>exit)
? { _tag: "Success" | "Failure"_tag: "Success", value: anyvalue: exit: Exit_.Success<
A["Encoded"],
E["Encoded"]
>
(parameter) exit: {
_tag: "Success";
value: A;
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;
}
exit.value } as type const = {
readonly _tag: "Success";
readonly value: any;
}
const
: { _tag: "Success" | "Failure"_tag: "Failure", cause: Cause_.Cause<E["Encoded"]>(property) cause: {
reasons: ReadonlyArray<Reason<E>>;
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;
}
cause: exit: Exit_.Failure<
A["Encoded"],
E["Encoded"]
>
(parameter) exit: {
_tag: "Failure";
cause: Cause.Cause<E>;
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;
}
exit.cause } as type const = {
readonly _tag: "Failure";
readonly cause: any;
}
const
})
),
Annotations.Declaration<Exit_.Exit<A["Type"], E["Type"]>, readonly [A, E, D]>.toArbitrary?: Annotations.ToArbitrary.Declaration<Exit_.Exit<A["Type"], E["Type"]>, readonly [A, E, D]> | undefinedtoArbitrary: ([value: Annotations.ToArbitrary.TypeParameter<
A["Type"]
>
(parameter) value: {
arbitrary: FastCheck.Arbitrary<T>;
terminal: FastCheck.Arbitrary<T> | undefined;
}
value, error: Annotations.ToArbitrary.TypeParameter<
E["Type"]
>
(parameter) error: {
arbitrary: FastCheck.Arbitrary<T>;
terminal: FastCheck.Arbitrary<T> | undefined;
}
error, defect: Annotations.ToArbitrary.TypeParameter<
D["Type"]
>
(parameter) defect: {
arbitrary: FastCheck.Arbitrary<T>;
terminal: FastCheck.Arbitrary<T> | undefined;
}
defect]) => (fc: typeof FastCheckfc, ctx: Annotations.ToArbitrary.Context(parameter) ctx: {
constraint: ToArbitrary.GenerationConstraint | undefined;
recursion: ToArbitrary.Recursion | undefined;
}
ctx) => {
const const cause: {
arbitrary: any
terminal: any
}
cause = function causeToArbitrary<E["Type"], D["Type"]>(error: Annotations.ToArbitrary.TypeParameter<E["Type"]>, defect: Annotations.ToArbitrary.TypeParameter<D["Type"]>): (fc: typeof FastCheck, ctx: Annotations.ToArbitrary.Context) => {
arbitrary: any;
terminal: any;
}
causeToArbitrary(error: Annotations.ToArbitrary.TypeParameter<
E["Type"]
>
(parameter) error: {
arbitrary: FastCheck.Arbitrary<T>;
terminal: FastCheck.Arbitrary<T> | undefined;
}
error, defect: Annotations.ToArbitrary.TypeParameter<
D["Type"]
>
(parameter) defect: {
arbitrary: FastCheck.Arbitrary<T>;
terminal: FastCheck.Arbitrary<T> | undefined;
}
defect)(fc: typeof FastCheckfc, ctx: Annotations.ToArbitrary.Context(parameter) ctx: {
constraint: ToArbitrary.GenerationConstraint | undefined;
recursion: ToArbitrary.Recursion | undefined;
}
ctx)
const const terminal: anyterminal = function oneOfArbitraries<unknown>(
fc: typeof FastCheck,
a: FastCheck.Arbitrary<unknown> | undefined,
b: FastCheck.Arbitrary<unknown> | undefined
): any
oneOfArbitraries(
fc: typeof FastCheckfc,
value: Annotations.ToArbitrary.TypeParameter<
A["Type"]
>
(parameter) value: {
arbitrary: FastCheck.Arbitrary<T>;
terminal: FastCheck.Arbitrary<T> | undefined;
}
value.Annotations.ToArbitrary.TypeParameter<T>.terminal: anyterminal?.map((v: anyv): import Exit_Exit_.type Exit_.Exit = /*unresolved*/ anyExit<function (type parameter) A in Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>A["Type"], function (type parameter) E in Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>E["Type"]> => import Exit_Exit_.succeed(v: anyv)),
const cause: {
arbitrary: any
terminal: any
}
cause.terminal: anyterminal?.map((cause: anycause): import Exit_Exit_.type Exit_.Exit = /*unresolved*/ anyExit<function (type parameter) A in Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>A["Type"], function (type parameter) E in Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>E["Type"]> => import Exit_Exit_.failCause(cause: anycause))
)
const const arbitrary: anyarbitrary = fc: typeof FastCheckfc.oneof(
value: Annotations.ToArbitrary.TypeParameter<
A["Type"]
>
(parameter) value: {
arbitrary: FastCheck.Arbitrary<T>;
terminal: FastCheck.Arbitrary<T> | undefined;
}
value.Annotations.ToArbitrary.TypeParameter<T>.arbitrary: FastCheck.Arbitrary<T>arbitrary.map((v: anyv): import Exit_Exit_.type Exit_.Exit = /*unresolved*/ anyExit<function (type parameter) A in Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>A["Type"], function (type parameter) E in Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>E["Type"]> => import Exit_Exit_.succeed(v: anyv)),
const cause: {
arbitrary: any
terminal: any
}
cause.arbitrary: anyarbitrary.map((cause: anycause): import Exit_Exit_.type Exit_.Exit = /*unresolved*/ anyExit<function (type parameter) A in Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>A["Type"], function (type parameter) E in Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>E["Type"]> => import Exit_Exit_.failCause(cause: anycause))
)
return function withRecursion<unknown>(
fc: typeof FastCheck,
ctx: Annotations.ToArbitrary.Context,
terminal:
| FastCheck.Arbitrary<unknown>
| undefined,
arbitrary: FastCheck.Arbitrary<unknown>
): {
arbitrary: any
terminal: any
}
withRecursion(fc: typeof FastCheckfc, ctx: Annotations.ToArbitrary.Context(parameter) ctx: {
constraint: ToArbitrary.GenerationConstraint | undefined;
recursion: ToArbitrary.Recursion | undefined;
}
ctx, const terminal: anyterminal, const arbitrary: anyarbitrary)
},
Annotations.Declaration<Exit_.Exit<A["Type"], E["Type"]>, readonly [A, E, D]>.toEquivalence?: Annotations.ToEquivalence.Declaration<Exit_.Exit<A["Type"], E["Type"]>, readonly [A, E, D]> | undefinedtoEquivalence: ([value: Equivalence.Equivalence<A["Type"]>value, error: Equivalence.Equivalence<E["Type"]>error, defect: Equivalence.Equivalence<D["Type"]>defect]) => {
const const cause: (
a: Cause_.Cause<unknown>,
b: Cause_.Cause<unknown>
) => any
cause = function causeToEquivalence<E>(
error: Equivalence.Equivalence<E>,
defect: Equivalence.Equivalence<unknown>
): (
a: Cause_.Cause<E>,
b: Cause_.Cause<E>
) => boolean
causeToEquivalence(error: Equivalence.Equivalence<E["Type"]>error, defect: Equivalence.Equivalence<D["Type"]>defect)
return (a: Exit_.Exit<A["Type"], E["Type"]>a, b: Exit_.Exit<A["Type"], E["Type"]>b) => {
if (a: Exit_.Exit<A["Type"], E["Type"]>a._tag !== b: Exit_.Exit<A["Type"], E["Type"]>b._tag) return false
switch (a: Exit_.Exit<A["Type"], E["Type"]>a._tag) {
case "Success":
return value: Equivalence.Equivalence<A["Type"]>value(a: Exit_.Success<A["Type"], E["Type"]>(parameter) a: {
_tag: "Success";
value: A;
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;
}
a.value, (b: Exit_.Exit<A["Type"], E["Type"]>b as import Exit_Exit_.type Exit_.Success = /*unresolved*/ anySuccess<function (type parameter) A in Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>A["Type"]>).value)
case "Failure":
return const cause: (
a: Cause_.Cause<unknown>,
b: Cause_.Cause<unknown>
) => any
cause(a: Exit_.Failure<A["Type"], E["Type"]>(parameter) a: {
_tag: "Failure";
cause: Cause.Cause<E>;
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;
}
a.cause, (b: Exit_.Exit<A["Type"], E["Type"]>b as import Exit_Exit_.type Exit_.Failure = /*unresolved*/ anyFailure<function (type parameter) E in Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>E["Type"], function (type parameter) D in Exit<A extends Constraint, E extends Constraint, D extends Constraint>(value: A, error: E, defect: D): Exit<A, E, D>D["Type"]>).cause)
}
}
},
Annotations.Declaration<Exit_.Exit<A["Type"], E["Type"]>, readonly [A, E, D]>.toFormatter?: Annotations.ToFormatter.Declaration<Exit_.Exit<A["Type"], E["Type"]>, readonly [A, E, D]> | undefinedtoFormatter: ([value: Formatter<A["Type"], string>value, error: Formatter<E["Type"], string>error, defect: Formatter<D["Type"], string>defect]) => {
const const cause: (
t: Cause_.Cause<unknown>
) => string
cause = function causeToFormatter<E>(
error: Formatter<E>,
defect: Formatter<unknown>
): (t: Cause_.Cause<E>) => string
causeToFormatter(error: Formatter<E["Type"], string>error, defect: Formatter<D["Type"], string>defect)
return (t: Exit_.Exit<A["Type"], E["Type"]>t) => {
switch (t: Exit_.Exit<A["Type"], E["Type"]>t._tag) {
case "Success":
return `Exit.Success(${value: Formatter<A["Type"], string>value(t: Exit_.Success<A["Type"], E["Type"]>(parameter) t: {
_tag: "Success";
value: A;
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;
}
t.value)})`
case "Failure":
return `Exit.Failure(${const cause: (
t: Cause_.Cause<unknown>
) => string
cause(t: Exit_.Failure<A["Type"], E["Type"]>(parameter) t: {
_tag: "Failure";
cause: Cause.Cause<E>;
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;
}
t.cause)})`
}
}
}
}
)
return const make: <S extends Constraint>(
ast: S["ast"],
options?: object
) => S
Creates a schema from an AST (Abstract Syntax Tree) node.
Details
This is the fundamental constructor for all schemas in the Effect Schema
library. It takes an AST node and wraps it in a fully-typed schema that
preserves all type information and provides the complete schema API.
The make function is used internally to create all primitive schemas like
String, Number, Boolean, etc., as well as more complex schemas. It's
the bridge between the untyped AST representation and the strongly-typed
schema.
make(const schema: declareConstructor<
Exit_.Exit<A["Type"], E["Type"]>,
Exit_.Exit<A["Encoded"], E["Encoded"]>,
readonly [A, E, D],
ExitIso<A, E, D>
>
const schema: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Annotations.Bottom<Exit_.Exit<A['Type'], E['Type']>, readonly [A, E, D]>) => declareConstructor<Exit_.Exit<A['Type'], E['Type']>, Exit_.Exit<A['Encoded'], E['Encoded']>, readonly [A, E, D], ExitIso<A, E, D>>;
annotateKey: (annotations: Annotations.Key<Exit_.Exit<A['Type'], E['Type']>>) => declareConstructor<Exit_.Exit<A['Type'], E['Type']>, Exit_.Exit<A['Encoded'], E['Encoded']>, readonly [A, E, D], ExitIso<A, E, D>>;
check: (checks_0: SchemaAST.Check<Exit_.Exit<A['Type'], E['Type']>>, ...checks: Array<SchemaAST.Check<Exit_.Exit<A['Type'], E['Type']>>>) => declareConstructor<Exit_.Exit<A['Type'], E['Type']>, Exit_.Exit<A['Encoded'], E['Encoded']>, readonly [A,…;
rebuild: (ast: SchemaAST.Declaration) => declareConstructor<Exit_.Exit<A['Type'], E['Type']>, Exit_.Exit<A['Encoded'], E['Encoded']>, readonly [A, E, D], ExitIso<A, E, D>>;
make: (input: Exit_.Exit<A['Type'], E['Type']>, options?: MakeOptions) => Exit_.Exit<A['Type'], E['Type']>;
makeOption: (input: Exit_.Exit<A['Type'], E['Type']>, options?: MakeOptions) => Option_.Option<Exit_.Exit<A['Type'], E['Type']>>;
makeEffect: (input: Exit_.Exit<A['Type'], E['Type']>, options?: MakeOptions) => Effect.Effect<Exit_.Exit<A['Type'], E['Type']>, SchemaError, never>;
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; <…;
}
schema.Bottom<Exit_.Exit<A["Type"], E["Type"]>, Exit_.Exit<A["Encoded"], E["Encoded"]>, (A | E | D)["DecodingServices"], (A | E | D)["EncodingServices"], Declaration, ... 9 more ..., "required">["ast"]: SchemaAST.Declaration(property) Bottom<Exit_.Exit<A["Type"], E["Type"]>, Exit_.Exit<A["Encoded"], E["Encoded"]>, (A | E | D)["DecodingServices"], (A | E | D)["EncodingServices"], Declaration, ... 9 more ..., "required">["ast"]: {
_tag: 'Declaration';
typeParameters: ReadonlyArray<AST>;
run: (typeParameters: ReadonlyArray<AST>) => (input: unknown, self: Declaration, options: ParseOptions) => Effect.Effect<any, SchemaIssue.Issue, any>;
encodingChecks: Checks | undefined;
getParser: () => SchemaParser.Parser;
_rebuild: (recur: (ast: AST) => AST, checks: Checks | undefined, encodingChecks: Checks | undefined) => Declaration;
recur: (recur: (ast: AST) => AST) => Declaration;
flip: (recur: (ast: AST) => AST) => Declaration;
getExpected: () => string;
annotations: Schema.Annotations.Annotations | undefined;
checks: Checks | undefined;
encoding: Encoding | undefined;
context: Context | undefined;
toString: () => string;
}
ast, { value: A extends Constraintvalue, error: E extends Constrainterror, defect: D extends Constraintdefect })
}