Functors with multiple arguments in OCaml

Viewed 4419

I've the following situation:

module type M = sig type s = ...  end

module Make(P: Something) : (M with type s = P.t) = struct
   type s = P.t
   ...
end

that works fine to generate modules of M type that use specific implementation of modules of type Something inside their implementation.

Now suppose I have another module defined as

module type AU = sig
  val feed : float -> unitv
  val nth : int -> (float -> float)
  val reset : unit -> unit
end

that has various implementations

module SUAlg : AU = struct ... end
module MLAlg : AU = struct ... end
module ACEAlg : AU = struct ... end

The point of the question is that the M module should be parametrized over two things now: a Something module and a AU module so that it's something like

module Make(P: Something) : (M with type s = P.t) = struct
   type s = P.t
   module Alg = MLAlg (* just an example *)
   ...
end

but I would like to have a generic functor that given a Something and given an AU it produces a module with both things concretized. Is there a way to obtain that easily?

Since functor syntax is quite strange and I'm still new to it I don't know if what I'm asking can be solved in a simple way or not.

Thanks in advance

1 Answers
Related