Asking for the correct way to use Core module with functor and `sexp`

OK, this is the working code using Comparator.S.

module Case_sexp_working = struct
  module My_Int = struct
    module T = struct
      type t = int [@@deriving compare, sexp]
    end

    include T
    include Comparator.Make (T)
  end

  type m = string Map.M(My_Int).t [@@deriving compare, sexp]

  module type TS = sig
    include module type of My_Int
    include Comparator.S with type t = t
  end

  module Make (S : TS) = struct
    type m = string Map.M(S).t [@@deriving compare, sexp]
  end
end

For the original code, the difference between Int (without signatures) and S : module type of Int may only be related to type constraints.

btw, it’s kind of hilarious that I asked a similar simpler question 4 years ago. I finally get used to putting more things in functors anyway.

I am still thinking if it’s possible to write the module interface on the fly e.g. Make (S : <on-the-fly>) instead of explicitly defining TS here.