Type: Task

class data.task.Task
type Task(α, β)

new ((α → Unit), (β → Unit) → γ), (γ → Unit)

implements
  Chain(β), Monad(β), Functor(β), Applicative(β),
  Semigroup(β), Monoid(β), ToString

A structure for time-dependent values.

Combining

#concat()

Task.prototype.concat(task)
@Task(α, β) => Task(α, β) → Task(α, β)

Selects the earlier of two Tasks.

Constructing

.of()

static Task.of(value)
β → Task(α, β)

Constructs a new Task containing the given successful value.

.rejected()

static Task.rejected(value)
α → Task(α, β)

Constructs a new Task containing the given failure value.

.empty()

static Task.empty()
Unit → Task(α, β)

Constructs a Task that will never resolve.

Transforming

#map()

Task.prototype.map(transformation)
@Task(α, β) => (β → γ) → Task(α, γ)

Transforms the successful value of the Task using a regular unary function.

#chain()

Task.prototype.chain(transformation)
@Task(α, β) => (β → Task(α, γ)) → Task(α, γ)

Transforms the succesful value of the Task using a function over monads.

#ap()

Task.prototype.ap(task)
@Task(α, β → γ) => Task(α, β) → Task(α, γ)

Transforms a Task by applying the function inside this receiver.

#orElse()

Task.prototype.orElse(transformation)
@Task(α, β) => (α → Task(γ, β)) → Task(γ, β)

Transforms the failure value of the Task into a new Task.

#fold()

Task.prototype.fold(onRejection, onSucecss)
@Task(α, β) => (α → γ), (β → γ) → Task(δ, γ)

Applies a function to each side of the task.

#cata()

Task.prototype.cata(pattern)
@Task(α, β) => { Rejected: α → γ, Resolved: β → γ } → Task(δ, γ)

Applies a function to each side of the task.

#swap()

Task.prototype.swap()
@Task(α, β) => Unit → Task(β, α)

Swaps the values in the task.

#bimap()

Task.prototype.bimap(onRejection, onSuccess)
@Task(α, β) => (α → γ), (β → δ) → Task(γ, δ)

Maps both sides of the task.

#rejectedMap()

Task.prototype.rejectedMap(transformation)
@Task(α, β) => (α → γ) → Task(γ, β)

Maps the failure side of the task.