tezos-base

Tezos: meta-package and pervasive type definitions for Tezos
Library tezos-base
type key = Table.key
type 'a t
val create : int -> 'a t
val clear : 'a t -> unit
val reset : 'a t -> unit

find_or_make t k gen is p if k is already bound to k in t. In this case, no side-effect is performed.

find_or_make t k gen is r if k is not bound in t where r is gen (). In this case, r becomes bound to k in t. In addition, a listener is added to r so that if r resolves to Error _, the binding is removed.

val remove : 'a t -> key -> unit
val find_opt : 'a t -> key -> 'a Tezos_error_monad.Error_monad.tzresult Lwt.t option

find_opt t k is None if there are no bindings for k in t, and Some p if p is bound to k in t.

val mem : 'a t -> key -> bool
val iter_s : ( key -> 'a -> unit Lwt.t ) -> 'a t -> unit Lwt.t
val iter_p : ( key -> 'a -> unit Lwt.t ) -> 'a t -> unit Lwt.t

iter_{s,p} f t iterates f over the promises of t. It blocks on unresolved promises and only applies the function on the ones that resolve successfully.

val fold : ( key -> 'a -> 'b -> 'b Lwt.t ) -> 'a t -> 'b -> 'b Lwt.t

fold f t init folds f over the successfully resolving promises of t. I.e., it goes through the promises in the table and waits for each of the promise to resolve in order to fold over it.

val fold_promises : ( key -> 'a Tezos_error_monad.Error_monad.tzresult Lwt.t -> 'b -> 'b ) -> 'a t -> 'b -> 'b

fold_promises f t init folds f over the promises of t.

val fold_resolved : ( key -> 'a -> 'b -> 'b ) -> 'a t -> 'b -> 'b

fold_resolved f t init folds f over the successfully resolved promises of t.

val fold_keys : ( key -> 'b -> 'b ) -> 'a t -> 'b -> 'b

fold_keys f t init folds f over the keys bound in t.

val length : 'a t -> int