Skip to content

Task

Task<A> = () => Promise<A>

Defined in: Core/Task.ts:25

A lazy async computation that always resolves.

Two guarantees:

  • Lazy — nothing starts until you call it.
  • Infallible — it never rejects. If failure is possible, encode it in the return type using TaskResult<E, A> instead.

A

Promise<A>

const getTimestamp: Task<number> = () => Promise.resolve(Date.now());

// Nothing runs yet — getTimestamp is just a description
const formatted = pipe(
  getTimestamp,
  Task.map(ts => new Date(ts).toISOString())
);

// Execute when ready
const result = await formatted();