package octez-libs
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=c6df840ebbf115e454db949028c595bec558a59a66cade73b52a6d099d6fa4d4
sha512=d8aee903b9fe130d73176bc8ec38b78c9ff65317da3cb4f3415f09af0c625b4384e7498201fdb61aa39086a7d5d409d0ab3423f9bc3ab989a680cf444a79bc13
doc/octez-libs.lwt-result-stdlib/Tezos_lwt_result_stdlib/Lwtreslib/Bare/index.html
Module Lwtreslib.BareSource
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.