Transform the Err value, passing Ok through unchanged. Useful for unifying heterogeneous failure types into one app-level union.
Err
Ok
type AppError = { kind: "http"; status: number } | { kind: "parse" };pipe( fetchSync(url), // Result<Body, { status: number }> mapErr((e): AppError => ({ kind: "http", status: e.status })),); Copy
type AppError = { kind: "http"; status: number } | { kind: "parse" };pipe( fetchSync(url), // Result<Body, { status: number }> mapErr((e): AppError => ({ kind: "http", status: e.status })),);
Transform the
Errvalue, passingOkthrough unchanged. Useful for unifying heterogeneous failure types into one app-level union.