<T, E, RD, RE>(codec: Codec<T, E, RD, RE>): Codec<T, E, RD, RE>Returns a codec widened to the full Codec interface, prompting
TypeScript to infer all four type parameters (T, E, RD, RE).
Details
When a schema is stored in a variable typed as Schema<T> or Top, the
encoded type and service requirements are erased. Passing the value through
revealCodec recovers those parameters without any runtime cost.
Example (Recovering encoded type from a schema variable)
import { Schema } from "effect"
const schema: Schema.Schema<number> = Schema.NumberFromString
// Without revealCodec, Encoded is unknown
const codec = Schema.revealCodec(schema)
type Enc = typeof codec["Encoded"] // stringexport function function revealCodec<T, E, RD, RE>(
codec: Codec<T, E, RD, RE>
): Codec<T, E, RD, RE>
Returns a codec widened to the full
Codec
interface, prompting
TypeScript to infer all four type parameters (T, E, RD, RE).
Details
When a schema is stored in a variable typed as Schema<T> or Top, the
encoded type and service requirements are erased. Passing the value through
revealCodec recovers those parameters without any runtime cost.
Example (Recovering encoded type from a schema variable)
import { Schema } from "effect"
const schema: Schema.Schema<number> = Schema.NumberFromString
// Without revealCodec, Encoded is unknown
const codec = Schema.revealCodec(schema)
type Enc = typeof codec["Encoded"] // string
revealCodec<function (type parameter) T in revealCodec<T, E, RD, RE>(codec: Codec<T, E, RD, RE>): Codec<T, E, RD, RE>T, function (type parameter) E in revealCodec<T, E, RD, RE>(codec: Codec<T, E, RD, RE>): Codec<T, E, RD, RE>E, function (type parameter) RD in revealCodec<T, E, RD, RE>(codec: Codec<T, E, RD, RE>): Codec<T, E, RD, RE>RD, function (type parameter) RE in revealCodec<T, E, RD, RE>(codec: Codec<T, E, RD, RE>): Codec<T, E, RD, RE>RE>(codec: Codec<T, E, RD, RE>(parameter) codec: {
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
Rebuild: Codec<T, E, RD, RE>;
Type: T;
Iso: Iso;
ast: Ast;
annotate: (annotations: Annotations.Bottom<T, any>) => Codec<T, E, RD, RE>;
annotateKey: (annotations: Annotations.Key<T>) => Codec<T, E, RD, RE>;
check: (checks_0: SchemaAST.Check<T>, ...checks: Array<SchemaAST.Check<T>>) => Codec<T, E, RD, RE>;
rebuild: (ast: SchemaAST.AST) => Codec<T, E, RD, RE>;
make: (input: unknown, options?: MakeOptions) => T;
makeOption: (input: unknown, options?: MakeOptions) => Option_.Option<T>;
makeEffect: (input: unknown, options?: MakeOptions) => Effect.Effect<T, 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; <…;
}
codec: interface Codec<out T, out E = T, out RD = never, out RE = never>Namespace of type-level helpers for
Codec
.
A schema that tracks the decoded type T, the encoded type E, and the
Effect services required during decoding (RD) and encoding (RE).
Details
Use Codec<T, E, RD, RE> when you need to preserve full type information
about a schema — both what it decodes to and what it serializes from/to.
Most concrete schemas produced by this module implement Codec.
For APIs that only need one direction, prefer the narrower views:
Decoder
<T, RD> — decode-only
Encoder
<E, RE> — encode-only
Schema
<T> — type-only (no encoded representation)
Example (Accepting a codec that decodes to number from string)
import { Schema } from "effect"
declare function serialize<T>(codec: Schema.Codec<T, string>): string
serialize(Schema.NumberFromString) // ok — decodes number, encoded as string
Codec<function (type parameter) T in revealCodec<T, E, RD, RE>(codec: Codec<T, E, RD, RE>): Codec<T, E, RD, RE>T, function (type parameter) E in revealCodec<T, E, RD, RE>(codec: Codec<T, E, RD, RE>): Codec<T, E, RD, RE>E, function (type parameter) RD in revealCodec<T, E, RD, RE>(codec: Codec<T, E, RD, RE>): Codec<T, E, RD, RE>RD, function (type parameter) RE in revealCodec<T, E, RD, RE>(codec: Codec<T, E, RD, RE>): Codec<T, E, RD, RE>RE>) {
return codec: Codec<T, E, RD, RE>(parameter) codec: {
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
Rebuild: Codec<T, E, RD, RE>;
Type: T;
Iso: Iso;
ast: Ast;
annotate: (annotations: Annotations.Bottom<T, any>) => Codec<T, E, RD, RE>;
annotateKey: (annotations: Annotations.Key<T>) => Codec<T, E, RD, RE>;
check: (checks_0: SchemaAST.Check<T>, ...checks: Array<SchemaAST.Check<T>>) => Codec<T, E, RD, RE>;
rebuild: (ast: SchemaAST.AST) => Codec<T, E, RD, RE>;
make: (input: unknown, options?: MakeOptions) => T;
makeOption: (input: unknown, options?: MakeOptions) => Option_.Option<T>;
makeEffect: (input: unknown, options?: MakeOptions) => Effect.Effect<T, 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; <…;
}
codec
}