Class: Task

lib/task~ Task

new Task()

((α → Void), (β → Void) → Void), (Void → Void) → Task[α, β] Task[α, β] <: Chain[β] , Monad[β] , Functor[β] , Applicative[β] , Semigroup[β] , Monoid[β] , Show

The Task[α, β] structure represents values that depend on time. This allows one to model time-based effects explicitly, such that one can have full knowledge of when they're dealing with delayed computations, latency, or anything that can not be computed immediately.

A common use for this structure is to replace the usual Continuation-Passing Style form of programming, in order to be able to compose and sequence time-dependent effects using the generic and powerful monadic operations.

Source:

Methods

<static> empty()

Void → Task[α, _]

Returns a Task that will never resolve

Source:

ap()

@Task[α, (β → γ)] => Task[α, β] → Task[α, γ]

Applys the successful value of the Task[α, (β → γ)] to the successful value of the Task[α, β]

Source:

bimap()

@Task[α, β] => (α → γ), (β → δ) → Task[γ, δ]

Maps both sides of the disjunction.

Source:

cata()

@Task[α, β] => { Rejected: α → γ, Resolved: β → γ } → Task[δ, γ]

Catamorphism.

Source:

chain()

@Task[α, β] => (β → Task[α, γ]) → Task[α, γ]

Transforms the succesful value of the Task[α, β] using a function to a monad.

Source:

concat()

@Task[α, β] => Task[α, β] → Task[α, β]

Selects the earlier of the two tasks Task[α, β]

Source:

fold()

@Task[α, β] => (α → γ), (β → γ) → Task[δ, γ]

Catamorphism. Takes two functions, applies the leftmost one to the failure value, and the rightmost one to the successful value, depending on which one is present.

Source:

map()

@Task[α, β] => (β → γ) → Task[α, γ]

Transforms the successful value of the Task[α, β] using a regular unary function.

Source:

of()

β → Task[α, β]

Constructs a new Task[α, β] containing the single value β.

β can be any value, including null, undefined, or another Task[α, β] structure.

Source:

orElse()

@Task[α, β] => (α → Task[γ, β]) → Task[γ, β]

Transforms a failure value into a new Task[α, β]. Does nothing if the structure already contains a successful value.

Source:

rejected()

α → Task[α, β]

Constructs a new Task[α, β] containing the single value α.

α can be any value, including null, undefined, or another Task[α, β] structure.

Source:

rejectedMap()

@Task[α, β] => (α → γ) → Task[γ, β]

Maps the left side of the disjunction (failure).

Source:

swap()

@Task[α, β] => Void → Task[β, α]

Swaps the disjunction values.

Source:

toString()

@Task[α, β] => Void → String

Returns a textual representation of the Task[α, β]

Source: