package b0

  1. Overview
  2. Docs
On This Page
  1. Future values
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module B0_std.FutSource

Future values.

A future is an undetermined value that becomes determined at an an arbitrary point in the future. The future acts as a placeholder for the value while it is undetermined.

Future values

Sourcetype 'a t

The type for futures with values of type 'a.

Sourceval make : unit -> 'a t * ('a -> unit)

make () is (f, set) with f the future value and set the function to set it. The latter can be called only once, Invalid_argument is raised otherwise.

Sourceval await : 'a t -> ('a -> unit) -> unit

await f k waits for f to be determined and continues with k v with v the value of the future. If the future never determines k is not invoked. k must not raise.

Sourceval value : 'a t -> 'a option

value f is f's value, if any.

Sourceval sync : 'a t -> 'a

sync f waits for f to determine. Warning. This is relaxed busy waiting.

Sourceval return : 'a -> 'a t

return v is a future that determines v.

Sourceval map : ('a -> 'b) -> 'a t -> 'b t

map fn f is return (fn v) with v the value of f.

Sourceval bind : 'a t -> ('a -> 'b t) -> 'b t

bind f fn is the future fn v with v the value of f.

Sourceval pair : 'a t -> 'b t -> ('a * 'b) t

pair f0 f1 determines with the value of f0 and f1.

Sourceval of_list : 'a t list -> 'a list t

of_list fs determines with the values of all fs, in the same order.

Sourcemodule Syntax : sig ... end

Future syntax.