Import
import { mapEffect } from "@typed/guard";Signatures
export declare const mapEffect: {
<O, B, E2, R2>(f: (o: O) => Effect.Effect<B, E2, R2>): <I, R, E>(guard: GuardInput<I, O, E, R>) => Guard<I, B, E | E2, R | R2>;
<I, O, E, R, B, E2, R2>(guard: GuardInput<I, O, E, R>, f: (o: O) => Effect.Effect<B, E2, R2>): Guard<I, B, E | E2, R | R2>;
};Why
Effectful mapping can add typed errors and services without changing non-match into failure.
Ownership and lifetime
Construction acquires no resources; the mapping Effect starts only after the source Guard produces Some.
Examples
import { liftPredicate, mapEffect } from "@typed/guard"
import { Effect } from "effect"
const length = mapEffect(liftPredicate((u: unknown): u is string => typeof u === "string"), (s) => Effect.succeed(s.length))