Module Fpath.Map

Path maps.

Path maps

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

dom m is the domain of m.

val of_list : (path * '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 : path -> '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) -> path -> '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.

Formatting

val pp : ?sep:unit Fmt.t -> (path * '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.