Class: Future

lib/future~ Future

new Future()

((α → Void), (β → Void) → Void) → Future[α, β] Future[α, β] <: Chain[β] , Monad[β] , Functor[β] , Show

The Future[α, β] 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

bimap()

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

Maps both sides of the disjunction.

Source:

chain()

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

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

Source:

fold()

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

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()

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

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

Source:

memoise()

((α → Void), (β → Void) → Void) → Future[α, β]

Creates a Future[α, β] that computes the action at most once.

Since this function will remember the resolved value of the future, it's expected to be used only for pure actions, otherwise you may not be able to observe the effects.

Source:

of()

β → Future[α, β]

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

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

Source:

orElse()

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

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

Source:

rejectedMap()

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

Maps the left side of the disjunction (failure).

Source:

swap()

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

Swaps the disjunction values.

Source:

toString()

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

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

Source: