Advice wanted on simplifying a Functor API (using a first class module function)


In a lib of ours, we have a functor which takes some modules, while some are the result of other functors as well. All of those functors share some modules as there arguments. (Also often using with constraints.)

I thought about simplifying the usage by defining a function using first class modules and labeled arguments.
Simplified example of my current situation:

module A = {..};
module B = {..};
module C = FunctorC(A, B);
module E = FunctorD(A, C);

I was thinking of an api like:

module A = {..};
module B = {..};
module D = fcmD(~a=(module A), ~b=(module B));

Do you see any problems in this approach?
Would you have an advice?

I’m currently trying to implement a prototype but struggling with aliasing some types to make them equal to the compiler.

As you can see we heavily use functors in this specific lib, but I’m missing the ocaml experience to know all the best practices.

disclosure: I asked this first on Discord.