Legend:
Library
Module
Module type
Parameter
Class
Class type
Future values.
A future 'a Fut.t is an undetermined value of type 'a that becomes determined at an arbitrary point in the future. The future acts as a placeholder for the value while it is undetermined.
Brr uses future values ('a, 'b) result Fut.t to type the resolution and rejection case of JavaScript promises. Since most rejection cases given by browser APIs are simply Jv.Error.t values, the dedicated Fut.or_error type alias can be used for that.
Fut.t values are indirectly implemented as Promise objects that never reject. You can't substitute them directly for JavaScript promises and vice-versa, use of_promise and to_promise to convert between them.
of_promise ~ok ~error p is a future for the promise p. The future determines with Ok (ok v) if p resolves with v and with Error (error e) if p rejects with e.
to_promise f is a JavaScript promise for the future f that resolves the promise with ok v if the future determines with Ok
v and rejects with e if the future determines with Error
e.