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