<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))
})export const 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 = <function (type parameter) T in <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>
T, function (type parameter) E in <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>
E, function (type parameter) RD in <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>
RD = never, function (type parameter) RE in <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>
RE = never>(options: {
readonly decode: SchemaGetter.Getter<T, E, RD>
readonly encode: SchemaGetter.Getter<E, T, RE>
}
options: {
readonly decode: SchemaGetter.Getter<T, E, RD>(property) decode: {
run: (input: Option.Option<E>, options: SchemaAST.ParseOptions) => Effect.Effect<Option.Option<T>, SchemaIssue.Issue, R>;
map: (f: (t: T) => T2) => SchemaGetter.Getter<T2, E, RD>;
compose: (other: SchemaGetter.Getter<T2, T, R2>) => SchemaGetter.Getter<T2, E, RD | 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.type SchemaGetter.Getter = /*unresolved*/ anyGetter<function (type parameter) T in <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>
T, function (type parameter) E in <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>
E, function (type parameter) RD in <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>
RD>
readonly encode: SchemaGetter.Getter<E, T, RE>(property) encode: {
run: (input: Option.Option<E>, options: SchemaAST.ParseOptions) => Effect.Effect<Option.Option<T>, SchemaIssue.Issue, R>;
map: (f: (t: E) => T2) => SchemaGetter.Getter<T2, T, RE>;
compose: (other: SchemaGetter.Getter<T2, E, R2>) => SchemaGetter.Getter<T2, T, RE | 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.type SchemaGetter.Getter = /*unresolved*/ anyGetter<function (type parameter) E in <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>
E, function (type parameter) T in <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>
T, function (type parameter) RE in <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>
RE>
}): class Transformation<in out T, in out E, RD = never, RE = never>class Transformation {
_tag: 'Transformation';
decode: SchemaGetter.Getter<T, E, RD>;
encode: SchemaGetter.Getter<E, T, RE>;
flip: () => Transformation<E, T, RE, RD>;
compose: <T2, RD2, RE2>(other: Transformation<T2, T, RD2, RE2>) => Transformation<T2, E, RD | RD2, RE | RE2>;
}
Represents a bidirectional transformation between a decoded type T and an encoded
type E, built from a pair of Getters.
When to use
Use when you need a schema transformation that defines how a schema converts
between two representations.
- You want to compose multiple transformations into a pipeline.
- You want to flip a transformation to swap decode/encode.
Details
This is the primary building block for Schema.decodeTo, Schema.encodeTo,
Schema.decode, Schema.encode, and Schema.link. Each direction is a
SchemaGetter.Getter that handles optionality, failure, and Effect services.
- Immutable —
flip() and compose() return new instances.
flip() swaps the decode and encode getters.
compose(other) chains: this.decode then other.decode for decoding,
other.encode then this.encode for encoding.
Example (Composing two transformations)
import { SchemaTransformation } from "effect"
const trimAndLower = SchemaTransformation.trim().compose(
SchemaTransformation.toLowerCase()
)
// decode: trim then lowercase
// encode: passthrough (both directions)
Transformation<function (type parameter) T in <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>
T, function (type parameter) E in <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>
E, function (type parameter) RD in <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>
RD, function (type parameter) RE in <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>
RE> => {
if (function isTransformation(
u: unknown
): u is Transformation<any, any, unknown, unknown>
Returns true if u is a Transformation instance.
When to use
Use to check whether a value is already a schema transformation before
wrapping it.
Details
- Pure predicate, no side effects.
- Acts as a TypeScript type guard.
Example (Checking a value)
import { SchemaTransformation } from "effect"
SchemaTransformation.isTransformation(SchemaTransformation.trim())
// true
SchemaTransformation.isTransformation({ decode: null, encode: null })
// false
isTransformation(options: {
readonly decode: SchemaGetter.Getter<T, E, RD>
readonly encode: SchemaGetter.Getter<E, T, RE>
}
options)) {
return options: {
readonly decode: SchemaGetter.Getter<T, E, RD>
readonly encode: SchemaGetter.Getter<E, T, RE>
}
options as any
}
return new constructor Transformation<T, E, RD, RE>(decode: SchemaGetter.Getter<T, E, RD>, encode: SchemaGetter.Getter<E, T, RE>): Transformation<T, E, RD, RE>Represents a bidirectional transformation between a decoded type T and an encoded
type E, built from a pair of Getters.
When to use
Use when you need a schema transformation that defines how a schema converts
between two representations.
- You want to compose multiple transformations into a pipeline.
- You want to flip a transformation to swap decode/encode.
Details
This is the primary building block for Schema.decodeTo, Schema.encodeTo,
Schema.decode, Schema.encode, and Schema.link. Each direction is a
SchemaGetter.Getter that handles optionality, failure, and Effect services.
- Immutable —
flip() and compose() return new instances.
flip() swaps the decode and encode getters.
compose(other) chains: this.decode then other.decode for decoding,
other.encode then this.encode for encoding.
Example (Composing two transformations)
import { SchemaTransformation } from "effect"
const trimAndLower = SchemaTransformation.trim().compose(
SchemaTransformation.toLowerCase()
)
// decode: trim then lowercase
// encode: passthrough (both directions)
Transformation(options: {
readonly decode: SchemaGetter.Getter<T, E, RD>
readonly encode: SchemaGetter.Getter<E, T, RE>
}
options.decode: SchemaGetter.Getter<T, E, RD>(property) decode: {
run: (input: Option.Option<E>, options: SchemaAST.ParseOptions) => Effect.Effect<Option.Option<T>, SchemaIssue.Issue, R>;
map: (f: (t: T) => T2) => SchemaGetter.Getter<T2, E, RD>;
compose: (other: SchemaGetter.Getter<T2, T, R2>) => SchemaGetter.Getter<T2, E, RD | 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, options: {
readonly decode: SchemaGetter.Getter<T, E, RD>
readonly encode: SchemaGetter.Getter<E, T, RE>
}
options.encode: SchemaGetter.Getter<E, T, RE>(property) encode: {
run: (input: Option.Option<E>, options: SchemaAST.ParseOptions) => Effect.Effect<Option.Option<T>, SchemaIssue.Issue, R>;
map: (f: (t: E) => T2) => SchemaGetter.Getter<T2, T, RE>;
compose: (other: SchemaGetter.Getter<T2, E, R2>) => SchemaGetter.Getter<T2, T, RE | 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)
}