Module MakeHeterogeneousMap.WithForeign

Parameters

module Map2 : BaseMap_S with type 'a key = 'a key

Signature

type ('map1, 'map2) polyinter_foreign = {
  1. f : 'a. 'a key -> ('a, 'map1) value -> ('a, 'map2) Map2.value -> ('a, 'map1) value;
}
val nonidempotent_inter : 'a t -> 'b Map2.t -> ('a, 'b) polyinter_foreign -> 'a t

Like inter. Tries to preserve physical equality on the first argument when possible.

type ('map2, 'map1) polyfilter_map_foreign = {
  1. f : 'a. 'a key -> ('a, 'map2) Map2.value -> ('a, 'map1) value option;
}

Like filter_map_no_share, but allows to transform a foreigh map into the current one.

val filter_map_no_share : 'map2 Map2.t -> ('map2, 'map1) polyfilter_map_foreign -> 'map1 t
type ('map1, 'map2) polyinsert_multiple = {
  1. f : 'a. 'a key -> ('a, 'map1) value option -> ('a, 'map2) Map2.value -> ('a, 'map1) value option;
}
val insert_multiple : 'a t -> 'b Map2.t -> ('a, 'b) polyinsert_multiple -> 'a t

This is equivalent to multiple calls to insert, where the key and values would be taken from the second map, i.e. insert_multiple f m1 m2 calls f on every key of m2 (in order of Key.to_inr), says if the corresponding value also exists in m1, and adds or remove the element in m1 depending on the value of f.

type ('map1, 'map2) polyremove_multiple = {
  1. f : 'a. 'a key -> ('a, 'map1) value -> ('a, 'map2) Map2.value -> ('a, 'map1) value option;
}
val remove_multiple : 'a t -> 'b Map2.t -> ('a, 'b) polyremove_multiple -> 'a t

This is equivalent to multiple calls to remove, where the key and values would be taken from the second map; i.e. remove_multiple f m1 m2 calls f.f on every binding that is in both m1 and m2, and either removes or changes it in m1. Bindings are passed to f.f in increasing order of Key.to_int.