Skip to content

TaskMaybe

TaskMaybe<A> = Task<Maybe<A>>

Defined in: Core/TaskMaybe.ts:18

TaskMaybe represents a lazy, infallible async operation that resolves to a Maybe<A>. It is a type alias for Task<Maybe<A>>.

Use Task.Maybe for async operations that can result in a missing value (e.g. database lookups).

A

const findUser = (id: string): Task.Maybe<User> =>
  Task.Maybe.tryCatch((signal) =>
    fetch(`/users/${id}`, { signal }).then(r => r.ok ? r.json() : null)
  );