ReasonML library to provide Future
and ResultFuture
monads as an alternative to Js.Promise.
The Future
is the most simple unit of evaluable value which can resolve at some point in the future. ResultFuture
is a future that eventually contains Belt.Result.t
result inside. This is the most useful replacement for Js.Promise because Js.Promise also contains the possibility of resolving to Ok value or rejection to Error value.
Special focus has been given to provide complete and yet compact set of utility functions to work with both Future and ResultFuture entities. Besides test coverage this library also contains a very basic memory performance test to ensure that memory gets freed (garbage collected) when Future has used the binded functions and evaluation is done.
npm install @rejs/re-future
Edit to bsconfig.json
:
"bs-dependencies": [..., "@rejs/re-future", ...],
This library is namespaced; to simplify access do:
module ResultFuture = RejsReFuture.ResultFuture;
// or
open RejsReFuture;
2553: <UNKNOWN SYNTAX ERROR>
Or you can open globally in your bsconfig.json
:
"bsc-flags": [ "-open RejsReFuture" ]
More usage examples also in the __tests__/
The most compact references of Future
and ResultFuture
are the interface files: