Module type B0.Hmap.MAP

module type MAP = sig .. end
Signature for heterogeneous maps.


Maps


type 'a key 
The type for keys whose lookup value is of type 'a.
type t 
The type for serializable heterogeneous value maps.
val empty : t
empty is the empty map.
val is_empty : t -> bool
is_empty m is true iff m is empty.
val mem : 'a key -> t -> bool
mem k m is true iff k is bound in m.
val add : 'a key -> 'a -> t -> t
add k v m is m with k bound to v.
val add_tag : bool key -> t -> t
add_tag k m is add k true m.
val singleton : 'a key -> 'a -> t
singleton k v is add k v empty.
val rem : 'a key -> t -> t
rem k m is m with k unbound.
val find : 'a key -> t -> 'a option
find k m is the value of k's binding in m, if any.
val get : 'a key -> t -> 'a
get k m is the value of k's binding in m.
Raises Invalid_argument if k is not bound in m.
val get_or_suggest : 'a key -> t -> ('a, string list) Pervasives.result
get_or_suggest k m is the value of k's binding in m or, if k is not bound in m it suggests alternative, key names found in m.
val flag : ?absent:bool -> bool key -> t -> bool
flag ~absent k m is the value of k in m or absent (defaults to false) if k is not bound in m.
type binding = 
| B : 'a key * 'a -> binding
The type for bindings.
val iter : (binding -> unit) -> t -> unit
iter f m applies f to all bindings of m.
val fold : (binding -> 'a -> 'a) -> t -> 'a -> 'a
fold f m acc folds over the bindings of m with f, starting with acc
val for_all : (binding -> bool) -> t -> bool
for_all p m is true iff all bindings of m satisfy p.
val exists : (binding -> bool) -> t -> bool
exists p m is true iff there exists a bindings of m that satisfies p.
val filter : (binding -> bool) -> t -> t
filter p m are the bindings of m that satisfy p.
val cardinal : t -> int
cardinal m is the number of bindings in m.
val any_binding : t -> binding option
any_binding m is a binding of m (if not empty).
val get_any_binding : t -> binding
get_any_binding m is a binding of m.
Raises Invalid_argument if m is empty.
val pp : t B0.Fmt.t

Serialization


type encode_error = string * [ `Msg of string ] 
The type for encode errors. The key name and the encoder error.
val encode : t -> (string * string) list * encode_error list
encode m is (l,errs) with l the bindings of m whose encoding suceeded and errs the bindings of m whose encoding failed.
type decode_error = string * [ `Msg of string | `Unknown ] 
The type for decoded binding errors. The key name and the error. `Unknown occurs if the key name does not exist in Key.list when the decode is performed.
val decode : (string * string) list -> t * decode_error list
decode bs is a map and a list of errors resulting from decoding the encoded binding list l.