lux/concurrency/promise

Types

Promise

Represents values produced by asynchronous computations (unlike IO, which is synchronous).

(type: (Promise a)
  (lux/concurrency/atom;Atom (Promise-State a)))

Macros

promise

## Makes an uninitialized Promise (in this example, of Unit).
(promise Unit)

## The type is optional.
(promise)

Structs

Applicative<Promise>

(lux/control/applicative;Applicative Promise)

Functor<Promise>

(lux/control/functor;Functor Promise)

Monad<Promise>

(lux/control/monad;Monad Promise)

Values

(alt left right)

Heterogeneous alternative combinator.

(All [a b] (-> (Promise a) (Promise b) (Promise (| a b))))

concurrency-level

lux;Nat

(delay time value)

Delivers a value after a certain period has passed.

(All [a] (-> lux;Nat a (Promise a)))

(either left right)

Homogeneous alternative combinator.

(All [a] (-> (Promise a) (Promise a) (Promise a)))

(future computation)

Runs an I/O computation on its own process and returns an Promise that will eventually host its result.

(All [a] (-> (lux/codata/io;IO a) (Promise a)))

(poll promise)

Checks whether an Promise's value has already been resolved.

(All [a] (-> (Promise a) (lux;Maybe a)))

(resolve value promise)

Sets an Promise's value if it hasn't been done yet.

(All [a] (-> a (Promise a) (lux/codata/io;IO lux;Bool)))

(seq left right)

Sequencing combinator.

(All [a b] (-> (Promise a) (Promise b) (Promise [a b])))

(time-out time promise)

Wait for a Promise to be resolved within the specified amount of milliseconds.

(All [a] (-> lux;Nat (Promise a) (Promise (lux;Maybe a))))

(wait time)

Returns a Promise that will be resolved after the specified amount of milliseconds.

(-> lux;Nat (Promise lux;Unit))