Skip to content

lift

lift<I, A>(f): Op<I, unknown, A>

Defined in: Core/Op.ts:526

Lifts a plain async function into an Op, treating all errors as unknown.

Use this when you have a simple async function that doesn’t need custom error mapping. The signal is passed so the operation can respect cancellation.

I

A

(input, signal) => Promise<A>

Op<I, unknown, A>

const fetchUser = Op.lift((id: number, signal: AbortSignal) =>
  fetch(`/api/users/${id}`, { signal }).then(r => r.json())
);
const manager = Op.interpret(fetchUser, { strategy: "restartable" });
const outcome = await manager.run(42);
if (Op.isOk(outcome)) console.log(outcome.value);