Functor implementing polymorphic module type... Help!

Yes, that’s basically it. To represent (in a module signature) “for some arbitrary type to be provided for by the module implementations”, rather than a type variable you need an abstract type in the signature, such as 'type t', combined as necessary with a 'with type t = ...' type equality qualification for the module implementations, for code using the module.

I think most people learning ocaml modules stub their toe on this at some point, particularly those who have used C++ templates. I certainly did. ML’s type system takes a little getting used to.

1 Like