package tezos-lwt-result-stdlib

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

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 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