package octez-libs
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=aa2f5bc99cc4ca2217c52a1af2a2cdfd3b383208cb859ca2e79ca0903396ca1d
sha512=d68bb3eb615e3dcccc845fddfc9901c95b3c6dc8e105e39522ce97637b1308a7fa7aa1d271351d5933febd7476b2819e1694f31198f1f0919681f1f9cc97cb3a
doc/octez-libs.lwt-result-stdlib/Tezos_lwt_result_stdlib/Lwtreslib/Bare/index.html
Module Lwtreslib.Bare
Source
Instance: Bare
Bare
provides all the functions as described above. It is intended to be opened to shadow some modules of Stdlib
.
All values within the modules follow the same naming and semantic conventions described above. The sequential traversors are fail-early: in the following example the code returns an Error
and does not print anything.
List.iter_e
(fun x ->
if x = "" then
Error "empty string"
else begin
print_endline x;
Ok ())
[
""; (* This will cause the iteration to stop *)
"this is not printed";
"neither is this printed";
]
The concurrent (parallel) traversors are best-effort: in the following example the code prints all the non-empty strings in an unspecified order before returning an Error
.
List.iter_ep
(fun x ->
if x = "" then
Lwt.return (Error "empty string")
else begin
print_endline x;
Lwt.return (Ok ()))
[
""; (* This will cause the iteration to error in the end *)
"this is printed";
"this is printed as well";
]
The module WithExceptions
provides some exception-raising helpers to reduce the boilerplate that the library imposes.
Comparison, Equality, etc.
When a function requires a comparison function, it takes a compare
named parameter. This must define a total order as described in Stdlib.Map.OrderedType
.
Note that the polymorphic structural comparison Stdlib.compare
is unsound for comparing some values; notably, it may fail when comparing data-structures that include functions or closures.
Similarly and for the same reason, some functions take an equal
function.