package tezos-error-monad

  1. Overview
  2. Docs

A trace is a stack of errors. It is implemented as an error list but such a list MUST NEVER be empty.

It is implemented as a concrete error list for backwards compatibility but future improvements might modify the type or render the type abstract.

include Sig.TRACE with type 'err trace = 'err list

The trace type (included as part of the Tezos_lwt_result_stdlib.Lwtreslib.TRACE module is abstract in this interface but it is made concrete in the instantiated error monad (see error_monad.mli).

The idea of abstracting the trace is so that it can evolve more easily. Eventually, we can make the trace abstract in the instantiated error monad, we can have different notions of traces for the protocol and the shell, etc.

include Tezos_lwt_result_stdlib.Lwtreslib.TRACE with type 'err trace = 'err list
type 'err trace = 'err list
val make : 'error -> 'error trace
val cons : 'error -> 'error trace -> 'error trace
val cons_list : 'error -> 'error list -> 'error trace
val conp : 'error trace -> 'error trace -> 'error trace
val conp_list : 'err trace -> 'err trace list -> 'err trace
val pp_print : (Stdlib.Format.formatter -> 'err -> unit) -> Stdlib.Format.formatter -> 'err trace -> unit

pp_print pretty-prints a trace of errors

val pp_print_top : (Stdlib.Format.formatter -> 'err -> unit) -> Stdlib.Format.formatter -> 'err trace -> unit

pp_print_top pretty-prints the top errors of the trace

val encoding : 'error Data_encoding.t -> 'error trace Data_encoding.t
val fold : ('a -> 'error -> 'a) -> 'a -> 'error trace -> 'a

fold f init trace traverses the trace (in an unspecified manner) so that init is folded over each of the error within trace by f. Typical use is to find the worst error, to check for the presence of a given error, etc.

OCaml

Innovation. Community. Security.