package octez-libs
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.
module Hashtbl : Bare_sigs.Hashtbl.S
module List : Bare_sigs.List.S
module Map : Bare_sigs.Map.S
module Monad : Bare_sigs.Monad.S
module Option : Bare_sigs.Option.S
module Result : Bare_sigs.Result.S
module Seq : Bare_sigs.Seq.S
module Seq_e : Bare_sigs.Seq_e.S
module Seq_s : Bare_sigs.Seq_s.S
module Set : Bare_sigs.Set.S
module Unit : Bare_sigs.Unit.S
module WithExceptions : Bare_sigs.WithExceptions.S