ocaml-trace/src/core/meta_map.mli
Simon Cruanes e50175298b
Add explicit spans, for async tracing.
These spans require the user to pass the surrounding span, if any, when
entering a new span. They use the information inside (which is collector
specific) to track what asynchronous task is currently being executed.

Wrappers around `trace`, specific to an async library (e.g. Eio, lwt,
Async, etc.) can then smooth this over by providing a `with_async_span`
construct that uses some implicit contextual storage to carry the
`surrounding` scope around.
2023-07-31 23:54:49 -04:00

37 lines
1 KiB
OCaml

(** Associative containers with Heterogeneous Values *)
(** Keys with a type witness. *)
module Key : sig
type 'a t
(** A key of type ['a t] is used to access the portion of the
map or table that associates keys of type ['a] to values. *)
val create : unit -> 'a t
(** Make a new key. This is generative, so calling [create ()] twice with the
same return type will produce incompatible keys that cannot see each
other's bindings. *)
val equal : 'a t -> 'a t -> bool
(** Compare two keys that have compatible types. *)
end
type pair = Pair : 'a Key.t * 'a -> pair
type t
(** Immutable map from {!Key.t} to values *)
val empty : t
val mem : _ Key.t -> t -> bool
val add : 'a Key.t -> 'a -> t -> t
val remove : _ Key.t -> t -> t
val length : t -> int
val cardinal : t -> int
val find : 'a Key.t -> t -> 'a option
val find_exn : 'a Key.t -> t -> 'a
(** @raise Not_found if the key is not in the table. *)
val iter : (pair -> unit) -> t -> unit
val add_list : t -> pair list -> t
val of_list : pair list -> t
val to_list : t -> pair list