Well if you don’t like the comparator_witness in generic maps (I’m not sure what do you mean by ugly), and just want your maps to have type `('a,'b) map`

while still having `('a,'b,'cmp) Base.Map.t`

as a backing store, you can hush the compare type using an existential. We need to be able to recover the type of the `comparator_witness`

so that we can compare maps to each other (as well as apply other binary methods on maps). For that we need to introduce an extra abstraction - the comparable type class^{1}. Everything else is trivial. See comments in the code, feel free to ask questions, if something is not clear.

```
module Map : sig
(** polymorphic finite mapping from ['k] to ['d] *)
type ('k,+'d) t
(** The comparable type class.
Should be moved to a separate module, but we will keep it here,
for the sake of experiment *)
type 'a comparable
(** [let int = declare (module T)] makes type [T.t] an instance
of the comparable type class. *)
val declare : (module Base.Comparator.S with type t = 'a) ->
'a comparable
(** {3 Map interface} *)
(** [empty comparable] creates an empty [map],
Example, [empty int].*)
val empty : 'k comparable -> ('k,'d) t
(** [find m k] returns data associated with [k] in [m]. *)
val find : ('k,'d) t -> 'k -> 'd option
(** [equal equal_values x y] is true if [xs] and [ys] are equal,
and have equal orderings.
*)
val equal : ('d -> 'd -> bool) -> ('k,'d) t -> ('k,'d) t -> bool
end = struct
type 'a comparable = Comparable : {
witness : 'c Type_equal.Id.t;
comparator : ('a,'c) Base.Comparator.comparator;
} -> 'a comparable
let declare (type t)
(module T : Base.Comparator.S with type t = t) = Comparable {
comparator = T.comparator;
witness = Type_equal.Id.create ~name:"comparable"
sexp_of_opaque
}
type ('k,+'d) t = Gen : {
witness : 'c Type_equal.Id.t;
map : ('k,'d,'c) Base.Map.t;
} -> ('k,'d) t
let find (Gen {map}) = Base.Map.find map
let equal value_equal (Gen lhs) (Gen rhs) =
match Type_equal.Id.same_witness lhs.witness rhs.witness with
| Some T -> Base.Map.equal value_equal lhs.map rhs.map
| None -> false
let empty (Comparable {comparator; witness}) = Gen {
witness;
map = Base.Map.Using_comparator.empty
~comparator
}
end
```

^{1)}We wouldn’t need this if Janestret will define their witness as an instance of `Type_equal.Id.t`

, instead of just keeping it a phantom. If they will agree to do this, then we can get rid of this intermediate abstraction.