Thanks for the comments. My objective was to abstract over the Zip compression library for portability reasons. I would like to target both native and JavaScript backends. I ended up with something like this:
module type Z = sig
type in_file
type entry
end
module type ContentType = sig
type t
type in_file
val make : in_file -> t
val do_something_with_t : t -> unit
val from_archive : in_file -> t
end
module MakeContent(Zip : Z) : (ContentType with type in_file = Zip.in_file) = struct
type in_file = Zip.in_file
type t = unit
let make _in_f = ()
let do_something_with_t _t = print_string "done"
let from_archive = make
end
(* In executable with a concrete implementation of Zip *)
let () =
let module ZipContent = MakeContent(Zip) in
let content = ZipContent.from_archive (Zip.open_in "archive.zip") in
ZipContent.do_something_with_t content
;;