Module String.Map

String maps.

String maps

include Stdlib.Map.S with type key := string with type 'a t = 'a Stdlib.Map.Make(Stdlib.String).t
type 'a t = 'a Stdlib.Map.Make(Stdlib.String).t
val empty : 'a t
val add : string -> 'a -> 'a t -> 'a t
val update : string -> ('a option -> 'a option) -> 'a t -> 'a t
val singleton : string -> 'a -> 'a t
val remove : string -> 'a t -> 'a t
val merge : (string -> 'a option -> 'b option -> 'c option) -> 'a t -> 'b t -> 'c t
val union : (string -> 'a -> 'a -> 'a option) -> 'a t -> 'a t -> 'a t
val cardinal : 'a t -> int
val bindings : 'a t -> (string * 'a) list
val min_binding : 'a t -> string * 'a
val min_binding_opt : 'a t -> (string * 'a) option
val max_binding : 'a t -> string * 'a
val max_binding_opt : 'a t -> (string * 'a) option
val choose : 'a t -> string * 'a
val choose_opt : 'a t -> (string * 'a) option
val find : string -> 'a t -> 'a
val find_opt : string -> 'a t -> 'a option
val find_first : (string -> bool) -> 'a t -> string * 'a
val find_first_opt : (string -> bool) -> 'a t -> (string * 'a) option
val find_last : (string -> bool) -> 'a t -> string * 'a
val find_last_opt : (string -> bool) -> 'a t -> (string * 'a) option
val iter : (string -> 'a -> unit) -> 'a t -> unit
val fold : (string -> 'a -> 'acc -> 'acc) -> 'a t -> 'acc -> 'acc
val map : ('a -> 'b) -> 'a t -> 'b t
val mapi : (string -> 'a -> 'b) -> 'a t -> 'b t
val filter : (string -> 'a -> bool) -> 'a t -> 'a t
val filter_map : (string -> 'a -> 'b option) -> 'a t -> 'b t
val partition : (string -> 'a -> bool) -> 'a t -> 'a t * 'a t
val split : string -> 'a t -> 'a t * 'a option * 'a t
val is_empty : 'a t -> bool
val mem : string -> 'a t -> bool
val equal : ('a -> 'a -> bool) -> 'a t -> 'a t -> bool
val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
val for_all : (string -> 'a -> bool) -> 'a t -> bool
val exists : (string -> 'a -> bool) -> 'a t -> bool
val to_list : 'a t -> (string * 'a) list
val to_seq : 'a t -> (string * 'a) Stdlib.Seq.t
val to_rev_seq : 'a t -> (string * 'a) Stdlib.Seq.t
val to_seq_from : string -> 'a t -> (string * 'a) Stdlib.Seq.t
val add_seq : (string * 'a) Stdlib.Seq.t -> 'a t -> 'a t
val of_seq : (string * 'a) Stdlib.Seq.t -> 'a t
type key = string
val dom : 'a t -> Set.t

dom m is the domain of m.

val of_list : (string * 'a) list -> 'a t

of_list bs is List.fold_left (fun m (k, v) -> add k v m) empty bs.

Additional adds

val add_to_list : string -> 'a -> 'a list t -> 'a list t

add k v m is m with k mapping to l such that l is v :: find k m if k was bound in m and [v] otherwise.

val add_to_set : (module Stdlib.Set.S with type elt = 'a and type t = 'set) -> string -> 'a -> 'set t -> 'set t

add (module S) k v m is m with k mapping to s such that s is S.add v (find k m) if k was bound in m and S.singleton [v] otherwise.

Get or hint

val get_or_suggest : string -> 'a t -> ('a, string list) Stdlib.result

get_or_suggest k m is Ok v if k is bound to v in m and otherwise a (possibly empty) list of suggested keys whose name could match name.

val get_or_hint : ?pp_key:string Fmt.t -> kind:string -> key -> 'a t -> ('a, string) Stdlib.result

get_or_hint is like get_or_suggest but it formats an error message that indicate that the kind of key k could not be found and suggests alternative names (if any). pp_key is used to format the keys, it default to Fmt.code'.

Formatting

val pp : ?sep:unit Fmt.t -> (string * 'a) Fmt.t -> 'a t Fmt.t

pp ~sep pp_binding ppf m formats the bindings of m on ppf. Each binding is formatted with pp_binding and bindings are separated by sep (defaults to Format.pp_print_cut). If the map is empty leaves ppf untouched.

val pp_dump : 'a Fmt.t -> 'a t Fmt.t

pp_dump pp_v ppf m prints an unspecified representation of m on ppf using pp_v to print the map codomain elements.

val pp_dump_string_map : string t Fmt.t

pp_dump_string_map ppf m prints an unspecified representation of the string map m on ppf.