Is there a way to have an unreferenced module in functor definition without the warning?

Hello,

I am writing a library at the moment where I am attempting to use functors to refactor some code to make it more flexible and easier to use before I think about possibly releasing it. I have a question about how functors work because there seems to be a gap in my knowledge.

I have a Make functor which uses an injected module where some types and functions will be defined by the user of the output of the Make functor. The injected module is only needed for the Make functor to use the functions and types internally to itself. There is no need for the injected module to appear in the public signature of the module that is output by Make. When I attempt do this in the Make module signature, I get an unused functor warning (specifically, Error (warning 67 [unused-functor-parameter]): unused functor parameter.). I know I can just ignore the warning but I was wondering if there might be a better way to handle this situation?

I have some cut down example code if anyone needs to see some code.

Thank you for your help!

Try using an underscore _ as the name of the argument module in the functor signature.

That worked! Thank you!

Just for anyone else who stumbles on this, you need to do something like this:

module Make(_ : Injected.S) :
sig
     val some_func : string -> int
end

FYI, you can even have:

module Make : Injected.S ->
sig
     val some_func : string -> int
end

Cheers,
Nicolas

1 Like