You can’t do exactly what you want (define a polymorphic set) but something close:
(*first your signature for set should be*)
module type Set = sig
type t (*the type of the sets*)
type elt (*the type of the elements*)
val empty : t
val mem : elt -> t -> bool
val add : elt -> t -> t
val elts : t -> elt list
end
and then use your implementation with this type annotation:
module ListSet (M : Equal) : Set with type elt = M.t = struct
(* put your implementation as above*)
end
Maybe this post could help you to understand a little bit more.