package octez-libs

  1. Overview
  2. Docs

Parameters

module Key : KeyS

Signature

type key = Key.t
type 'a producer = key -> 'a Lwt.t
module Map : Map.S with type key = key
type 'a t
val origin : 'a t -> Tezos_tree_encoding.wrapped_tree option

origin map returns the tree of origin of the map, if it exists.

Note: The sole consumer of this function is expected to be the tree-encoding library.

val string_of_key : key -> string

string_of_key key turns the given key into a string.

val pp : (Format.formatter -> 'a -> unit) -> Format.formatter -> 'a t -> unit

pp pp_value gives you a pretty-printer. This function is a witness of internal mutation.

val to_string : ('a -> string) -> 'a t -> string

to_string show map generates a string representation of map by using show for its values. Like pp this function is witness of internal mutation.

val create : ?values:'a Map.t -> ?produce_value:'a producer -> ?origin:Tezos_tree_encoding.wrapped_tree -> unit -> 'a t

create ?values ?produce_value ?origin num_elements produces a lazy map with num_elements entries where each is created using produce_value. values may be provided to supply an initial set of entries.

Note: This function is intended to be used produce_value should only be used by the tree-encoding library. If you want to fill a newly created map with some value, use values or set on the empty map.

val get : key -> 'a t -> 'a Lwt.t

get key map retrieves the element at key.

  • raises UnexpectedAccess

    when trying to access an invalid key (e.g., when the key has been deleted).

val set : key -> 'a -> 'a t -> 'a t

set key value map sets the element at key to value.

  • raises Exn.Bounds

    when trying to set an invalid key

val remove : key -> 'a t -> 'a t

remove key map marks the element at key as removed.

val dup : 'a t -> 'a t

dup map duplicates map.

Note: the produce_value continuation is shared between the resulting map and map, meaning that if said continuation carries a state, the two maps will interfere with each others. This is safe when used in conjunction with lib_tree_encoding, because the continuation is pure in the sense it will always returns the same result when called with the same argument.

val loaded_bindings : 'a t -> (key * 'a option) list

loaded_bindings map returns the (key * 'a) list representation of the map map containing only the loaded values, in order of increasing keys. This function is a witness of internal mutations.

OCaml

Innovation. Community. Security.