Hi,

I've problems in writing an Identity Functor in OCAML that I want to use as a wrapper module.

Consider the following OCAML definition containing the type IHelloWorld, the module World, an Identity functor
defined in the module Wrapper, and the binding of World to Wrapper in the module TestWrapper:

      module type IHelloWorld =
      sig
         type helloWorldType = Hello | World
        val hello : unit -> helloWorldType
      end

      module Wrapper (X: IHelloWorld) : IHelloWorld =
      struct
        type helloWorldType = X.helloWorldType
        let hello = X.hello
      end

      module World : IHelloWorld =
      struct
         type helloWorldType = Hello | World
         let hello () = Hello
      end

      module TestWrapper = Wrapper(World)

If I compile this module I get the following output from the OCAML compiler

      mdejonge> ocamlc wrapper-demo.ml
      File "wrapper-demo.ml", line 8, characters 3-85:
      Signature mismatch:
      Modules do not match:
        sig
          type helloWorldType = X.helloWorldType
          val hello : unit -> X.helloWorldType
        end
      is not included in
        IHelloWorld
     Type declarations do not match:
        type helloWorldType = X.helloWorldType
      is not included in
        type helloWorldType = Hello | World

If I change helloWorldType into "int" and let the definition of hello yield (say) 10:

      type helloWorldType = int
      let hello () = 10

Then the compiler issues no error at all!

Using a "with type" construct in the module definition of Wrapper does not work:

      module Wrapper (X: IHelloWorld) : IHelloWorld  with type helloWorldType = X.helloWorldType =

I don't understand what is going on. Can anyone help me understanding this problem and help me
writing a wrapper module as above?

Many thanks in advance

Best regards,
Merijn de Jonge