package octez-libs

  1. Overview
  2. Docs
A package that contains multiple base libraries used by the Octez suite

Install

Dune Dependency

Authors

Maintainers

Sources

tezos-octez-v20.1.tag.bz2
sha256=ddfb5076eeb0b32ac21c1eed44e8fc86a6743ef18ab23fff02d36e365bb73d61
sha512=d22a827df5146e0aa274df48bc2150b098177ff7e5eab52c6109e867eb0a1f0ec63e6bfbb0e3645a6c2112de3877c91a17df32ccbff301891ce4ba630c997a65

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.

Sourcemodule Seq_es : Bare_sigs.Seq_es.S with type ('a, 'e) seq_e_t := ('a, 'e) Seq_e.t and type 'a seq_s_t := 'a Seq_s.t
OCaml

Innovation. Community. Security.