Import
import { encode } from "@typed/guard";Signatures
export declare const encode: {
<S extends Schema.Top>(schema: S): <I, E = never, R = never>(guard: GuardInput<I, S["Type"], E, R>) => Guard<I, S["Encoded"], Schema.SchemaError | E, R | S["EncodingServices"]>;
<I, E, R, S extends Schema.Top>(guard: GuardInput<I, S["Type"], E, R>, schema: S): Guard<I, S["Encoded"], Schema.SchemaError | E, R | S["EncodingServices"]>;
};Why
The composed Guard preserves source non-match and errors while adding schema failures and encoding service requirements.
Ownership and lifetime
Construction acquires no resources; encoding starts only for Some and follows that invocation’s lifetime.
Examples
import { encode, liftPredicate } from "@typed/guard"
import { Schema } from "effect"
const text = encode(liftPredicate((u: unknown): u is number => typeof u === "number"), Schema.NumberFromString)