overrideToCodecIso<S, Iso>Overrides a schema's derived ISO codec with an explicit target codec.
When to use
Use to provide a custom ISO transformation when the default derivation is not appropriate.
Details
The resulting schema carries a custom Iso type parameter and uses the
provided decode and encode getters to transform between the schema type
and the target codec.
export interface interface overrideToCodecIso<S extends Constraint, Iso>Overrides a schema's derived ISO codec with an explicit target codec.
When to use
Use to provide a custom ISO transformation when the default derivation is not
appropriate.
Details
The resulting schema carries a custom Iso type parameter and uses the
provided decode and encode getters to transform between the schema type
and the target codec.
Type-level representation returned by
overrideToCodecIso
.
overrideToCodecIso<function (type parameter) S in overrideToCodecIso<S extends Constraint, Iso>S extends Constraint, function (type parameter) Iso in overrideToCodecIso<S extends Constraint, Iso>Iso> extends
interface BottomLazy<out Ast extends SchemaAST.AST, out Rebuild extends Top, in out TypeParameters extends ReadonlyArray<Constraint> = readonly [], out TypeMutability extends Mutability = "readonly", out TypeOptionality extends Optionality = "required", out TypeConstructorDefault extends ConstructorDefault = "no-default", out EncodedMutability extends Mutability = "readonly", out EncodedOptionality extends Optionality = "required">Lazy Bottom variant for schema implementations that compute their public
views on demand.
When to use
Use as an implementation base for schema interfaces that must expose
Bottom behavior without forcing TypeScript to eagerly evaluate expensive
Type, Encoded, or service views.
Details
The laziness is purely type-level; runtime behavior is unchanged.
BottomLazy keeps the structural operations inherited from Bottom, but
erases the expensive schema views to unknown. Concrete schema interfaces can
then redeclare the precise views they expose. This keeps wide schemas such as
Struct and Union cheaper when generic code reads a single view, while
preserving their exact public types.
BottomLazy<
function (type parameter) S in overrideToCodecIso<S extends Constraint, Iso>S["ast"],
interface overrideToCodecIso<S extends Constraint, Iso>Overrides a schema's derived ISO codec with an explicit target codec.
When to use
Use to provide a custom ISO transformation when the default derivation is not
appropriate.
Details
The resulting schema carries a custom Iso type parameter and uses the
provided decode and encode getters to transform between the schema type
and the target codec.
Type-level representation returned by
overrideToCodecIso
.
overrideToCodecIso<function (type parameter) S in overrideToCodecIso<S extends Constraint, Iso>S, function (type parameter) Iso in overrideToCodecIso<S extends Constraint, Iso>Iso>,
function (type parameter) S in overrideToCodecIso<S extends Constraint, Iso>S["~type.parameters"],
function (type parameter) S in overrideToCodecIso<S extends Constraint, Iso>S["~type.mutability"],
function (type parameter) S in overrideToCodecIso<S extends Constraint, Iso>S["~type.optionality"],
function (type parameter) S in overrideToCodecIso<S extends Constraint, Iso>S["~type.constructor.default"],
function (type parameter) S in overrideToCodecIso<S extends Constraint, Iso>S["~encoded.mutability"],
function (type parameter) S in overrideToCodecIso<S extends Constraint, Iso>S["~encoded.optionality"]
>
{
readonly "Type": function (type parameter) S in overrideToCodecIso<S extends Constraint, Iso>S["Type"]
readonly "Encoded": function (type parameter) S in overrideToCodecIso<S extends Constraint, Iso>S["Encoded"]
readonly "DecodingServices": function (type parameter) S in overrideToCodecIso<S extends Constraint, Iso>S["DecodingServices"]
readonly "EncodingServices": function (type parameter) S in overrideToCodecIso<S extends Constraint, Iso>S["EncodingServices"]
readonly "~type.make.in": function (type parameter) S in overrideToCodecIso<S extends Constraint, Iso>S["~type.make.in"]
readonly "~type.make": function (type parameter) S in overrideToCodecIso<S extends Constraint, Iso>S["~type.make"]
readonly "Iso": function (type parameter) Iso in overrideToCodecIso<S extends Constraint, Iso>Iso
readonly overrideToCodecIso<S extends Constraint, Iso>.schema: S extends Constraintschema: function (type parameter) S in overrideToCodecIso<S extends Constraint, Iso>S
}
/**
* Overrides a schema's derived ISO codec with an explicit target codec.
*
* **When to use**
*
* Use to provide a custom ISO transformation when the default derivation is not
* appropriate.
*
* **Details**
*
* The resulting schema carries a custom `Iso` type parameter and uses the
* provided `decode` and `encode` getters to transform between the schema type
* and the target codec.
*
* @category Optic
* @since 4.0.0
*/
export function function overrideToCodecIso<
S extends Constraint,
Iso
>(
to: ConstraintCodec<Iso>,
transformation: {
readonly decode: SchemaGetter.Getter<
S["Type"],
Iso
>
readonly encode: SchemaGetter.Getter<
Iso,
S["Type"]
>
}
): (schema: S) => overrideToCodecIso<S, Iso>
Overrides a schema's derived ISO codec with an explicit target codec.
When to use
Use to provide a custom ISO transformation when the default derivation is not
appropriate.
Details
The resulting schema carries a custom Iso type parameter and uses the
provided decode and encode getters to transform between the schema type
and the target codec.
overrideToCodecIso<function (type parameter) S in overrideToCodecIso<S extends Constraint, Iso>(to: ConstraintCodec<Iso>, transformation: {
readonly decode: SchemaGetter.Getter<S["Type"], Iso>;
readonly encode: SchemaGetter.Getter<Iso, S["Type"]>;
}): (schema: S) => overrideToCodecIso<S, Iso>
S extends Constraint, function (type parameter) Iso in overrideToCodecIso<S extends Constraint, Iso>(to: ConstraintCodec<Iso>, transformation: {
readonly decode: SchemaGetter.Getter<S["Type"], Iso>;
readonly encode: SchemaGetter.Getter<Iso, S["Type"]>;
}): (schema: S) => overrideToCodecIso<S, Iso>
Iso>(
to: ConstraintCodec<Iso>(parameter) to: {
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
ast: SchemaAST.AST;
Iso: unknown;
}
to: interface ConstraintCodec<out T, out E = T, out RD = never, out RE = never>Lightweight structural constraint for APIs that need codec type views but do
not need the full schema protocol.
When to use
Use when you need to preserve decoded type, encoded type, and service
requirements for a schema value, but the API does not call schema methods
such as annotate, check, rebuild, make, or makeEffect.
ConstraintCodec<function (type parameter) Iso in overrideToCodecIso<S extends Constraint, Iso>(to: ConstraintCodec<Iso>, transformation: {
readonly decode: SchemaGetter.Getter<S["Type"], Iso>;
readonly encode: SchemaGetter.Getter<Iso, S["Type"]>;
}): (schema: S) => overrideToCodecIso<S, Iso>
Iso>,
transformation: {
readonly decode: SchemaGetter.Getter<
S["Type"],
Iso
>
readonly encode: SchemaGetter.Getter<
Iso,
S["Type"]
>
}
transformation: {
readonly decode: SchemaGetter.Getter<S["Type"], Iso>(property) decode: {
run: (input: Option.Option<E>, options: SchemaAST.ParseOptions) => Effect.Effect<Option.Option<T>, SchemaIssue.Issue, R>;
map: (f: (t: S['Type']) => T2) => SchemaGetter.Getter<T2, Iso, never>;
compose: (other: SchemaGetter.Getter<T2, S['Type'], R2>) => SchemaGetter.Getter<T2, Iso, R2>;
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; <…;
}
decode: import SchemaGetterSchemaGetter.class Getter<out T, in E, R = never>class Getter {
run: (input: Option.Option<E>, options: SchemaAST.ParseOptions) => Effect.Effect<Option.Option<T>, SchemaIssue.Issue, R>;
map: <T2>(f: (t: T) => T2) => Getter<T2, E, R>;
compose: <T2, R2>(other: Getter<T2, T, R2>) => Getter<T2, E, R | R2>;
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; <…;
}
Represents a composable transformation from an encoded type E to a decoded type T.
When to use
Use when you need a schema getter to build and compose custom transformations
for Schema.decodeTo or Schema.decode.
Details
A getter wraps a function Option<E> -> Effect<Option<T>, Issue, R>. It
receives Option.None when the encoded key is absent, such as a missing
struct field, and returns Option.None to omit the value from the decoded
output. It fails with Issue on invalid input and may require Effect
services via R. .map(f) applies f to the decoded value inside Some
while leaving None unchanged. .compose(other) chains two getters by
feeding the output of this into other; passthrough getters on either side
are optimized away.
Example (Creating and composing getters)
import { SchemaGetter } from "effect"
const parseNumber = SchemaGetter.transform<number, string>((s) => Number(s))
const double = SchemaGetter.transform<number, number>((n) => n * 2)
const composed = parseNumber.compose(double)
// composed: Getter<number, string> — parses then doubles
Getter<function (type parameter) S in overrideToCodecIso<S extends Constraint, Iso>(to: ConstraintCodec<Iso>, transformation: {
readonly decode: SchemaGetter.Getter<S["Type"], Iso>;
readonly encode: SchemaGetter.Getter<Iso, S["Type"]>;
}): (schema: S) => overrideToCodecIso<S, Iso>
S["Type"], function (type parameter) Iso in overrideToCodecIso<S extends Constraint, Iso>(to: ConstraintCodec<Iso>, transformation: {
readonly decode: SchemaGetter.Getter<S["Type"], Iso>;
readonly encode: SchemaGetter.Getter<Iso, S["Type"]>;
}): (schema: S) => overrideToCodecIso<S, Iso>
Iso>
readonly encode: SchemaGetter.Getter<Iso, S["Type"]>(property) encode: {
run: (input: Option.Option<E>, options: SchemaAST.ParseOptions) => Effect.Effect<Option.Option<T>, SchemaIssue.Issue, R>;
map: (f: (t: Iso) => T2) => SchemaGetter.Getter<T2, S['Type'], never>;
compose: (other: SchemaGetter.Getter<T2, Iso, R2>) => SchemaGetter.Getter<T2, S['Type'], R2>;
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; <…;
}
encode: import SchemaGetterSchemaGetter.class Getter<out T, in E, R = never>class Getter {
run: (input: Option.Option<E>, options: SchemaAST.ParseOptions) => Effect.Effect<Option.Option<T>, SchemaIssue.Issue, R>;
map: <T2>(f: (t: T) => T2) => Getter<T2, E, R>;
compose: <T2, R2>(other: Getter<T2, T, R2>) => Getter<T2, E, R | R2>;
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; <…;
}
Represents a composable transformation from an encoded type E to a decoded type T.
When to use
Use when you need a schema getter to build and compose custom transformations
for Schema.decodeTo or Schema.decode.
Details
A getter wraps a function Option<E> -> Effect<Option<T>, Issue, R>. It
receives Option.None when the encoded key is absent, such as a missing
struct field, and returns Option.None to omit the value from the decoded
output. It fails with Issue on invalid input and may require Effect
services via R. .map(f) applies f to the decoded value inside Some
while leaving None unchanged. .compose(other) chains two getters by
feeding the output of this into other; passthrough getters on either side
are optimized away.
Example (Creating and composing getters)
import { SchemaGetter } from "effect"
const parseNumber = SchemaGetter.transform<number, string>((s) => Number(s))
const double = SchemaGetter.transform<number, number>((n) => n * 2)
const composed = parseNumber.compose(double)
// composed: Getter<number, string> — parses then doubles
Getter<function (type parameter) Iso in overrideToCodecIso<S extends Constraint, Iso>(to: ConstraintCodec<Iso>, transformation: {
readonly decode: SchemaGetter.Getter<S["Type"], Iso>;
readonly encode: SchemaGetter.Getter<Iso, S["Type"]>;
}): (schema: S) => overrideToCodecIso<S, Iso>
Iso, function (type parameter) S in overrideToCodecIso<S extends Constraint, Iso>(to: ConstraintCodec<Iso>, transformation: {
readonly decode: SchemaGetter.Getter<S["Type"], Iso>;
readonly encode: SchemaGetter.Getter<Iso, S["Type"]>;
}): (schema: S) => overrideToCodecIso<S, Iso>
S["Type"]>
}
) {
return (schema: S extends Constraintschema: function (type parameter) S in overrideToCodecIso<S extends Constraint, Iso>(to: ConstraintCodec<Iso>, transformation: {
readonly decode: SchemaGetter.Getter<S["Type"], Iso>;
readonly encode: SchemaGetter.Getter<Iso, S["Type"]>;
}): (schema: S) => overrideToCodecIso<S, Iso>
S): interface overrideToCodecIso<S extends Constraint, Iso>Overrides a schema's derived ISO codec with an explicit target codec.
When to use
Use to provide a custom ISO transformation when the default derivation is not
appropriate.
Details
The resulting schema carries a custom Iso type parameter and uses the
provided decode and encode getters to transform between the schema type
and the target codec.
Type-level representation returned by
overrideToCodecIso
.
overrideToCodecIso<function (type parameter) S in overrideToCodecIso<S extends Constraint, Iso>(to: ConstraintCodec<Iso>, transformation: {
readonly decode: SchemaGetter.Getter<S["Type"], Iso>;
readonly encode: SchemaGetter.Getter<Iso, S["Type"]>;
}): (schema: S) => overrideToCodecIso<S, Iso>
S, function (type parameter) Iso in overrideToCodecIso<S extends Constraint, Iso>(to: ConstraintCodec<Iso>, transformation: {
readonly decode: SchemaGetter.Getter<S["Type"], Iso>;
readonly encode: SchemaGetter.Getter<Iso, S["Type"]>;
}): (schema: S) => overrideToCodecIso<S, Iso>
Iso> => {
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(
import SchemaASTSchemaAST.function annotate<A extends AST>(
ast: A,
annotations: Schema.Annotations.Annotations
): A
annotate(schema: S extends Constraintschema.Constraint["ast"]: SchemaAST.ASTast, {
toCodecIso: () => SchemaAST.LinktoCodecIso: () => new import SchemaASTSchemaAST.constructor Link(to: SchemaAST.AST, transformation: SchemaTransformation.Transformation<any, any, any, any> | SchemaTransformation.Middleware<any, any, any, any, any, any>): SchemaAST.LinkRepresents a single step in an
Encoding
chain.
Details
A link pairs a target
AST
with a Transformation or Middleware
that converts values between the current node and the target.
to — the AST node on the other side of this transformation step.
transformation — the bidirectional conversion logic (decode/encode).
Links are composed into a non-empty array (
Encoding
) attached to
AST nodes that have a different encoded representation.
Link(to: ConstraintCodec<Iso>(parameter) to: {
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
ast: SchemaAST.AST;
Iso: unknown;
}
to.Constraint["ast"]: SchemaAST.ASTast, import SchemaTransformationSchemaTransformation.const make: <
T,
E,
RD = never,
RE = never
>(options: {
readonly decode: SchemaGetter.Getter<T, E, RD>
readonly encode: SchemaGetter.Getter<E, T, RE>
}) => Transformation<T, E, RD, RE>
Constructs a Transformation from an object with decode and encode
Getters. If the input is already a Transformation, returns it as-is.
When to use
Use when you already have schema getter instances and want to pair them into
a schema transformation.
- You want idempotent wrapping (won't double-wrap).
Details
- Returns the input unchanged if it is already a
Transformation.
Example (Wrapping existing getters)
import { SchemaGetter, SchemaTransformation } from "effect"
const t = SchemaTransformation.make({
decode: SchemaGetter.transform<number, string>((s) => Number(s)),
encode: SchemaGetter.transform<string, number>((n) => String(n))
})
make(transformation: {
readonly decode: SchemaGetter.Getter<
S["Type"],
Iso
>
readonly encode: SchemaGetter.Getter<
Iso,
S["Type"]
>
}
transformation))
}),
{ schema: S extends Constraintschema }
)
}
}