title: Why is it impossible to include module type from functor parameter module into module type in resulting module of functor?
body: <p>OCaml doesn't provide the ability to create a module type by functor directly. But, It allows some manipulations with the nested module type. So, I can use module type from parameter to bind module type in the result:</p>
  <pre><code>module CONTAINER = struct
    module type S = sig
      val a : int
    end
  end
  
  module COPY (CONTAINER : sig module type S end) = struct
    module type S = CONTAINER.S
  end 
  
  module type S_FROM_CONTAINER = COPY(CONTAINER).S
      
  </code></pre>
  <p><code>S_FROM_CONTAINER</code> isn't abstract. It is necessary to provide <code>a</code> to apply <code>S_FROM_CONTAINER</code>.</p>
  <pre><code>(*
  module Impl : S_FROM_CONTAINER = struct
  end 
  
  &gt; Error: Signature mismatch:
  &gt; Modules do not match: sig end is not included in S_FROM_CONTAINER  
  &gt; The value `a' is required but not provided
  *)
  
  module Impl : S_FROM_CONTAINER = struct
    let a = 42
  end 
  </code></pre>
  <p>Also, I can use <code>S</code> from <code>CONTAINER</code> as a type of module in module type in the resulting module:</p>
  <pre><code>module AS_TYPE_OF_IMPL (CONTAINER : sig module type S end) = struct
    module type S = sig
      module Impl : CONTAINER.S 
    end
  end 
  
  module type IMPL_CONTAINER_S = 
    AS_TYPE_OF_IMPL(CONTAINER).S 
  </code></pre>
  <p><code>Impl</code> module in <code>IMPL_CONTAINER_S</code> isn't abstract module type too:</p>
  <pre><code>(* module ImplContainer : IMPL_CONTAINER_S = struct
       module Impl = struct end
     end
  
  &gt; Error: Signature mismatch:
  &gt; Modules do not match:
  &gt;   sig module Impl : sig end end
  &gt; is not included in
  &gt;   IMPL_CONTAINER_S
  &gt; In module Impl:
  &gt; Modules do not match: sig end is not included in CONTAINER.S
  &gt; In module Impl:
  &gt; The value `a' is required but not provided
  *)
  
  module ImplContainer : IMPL_CONTAINER_S = struct
    module Impl = struct let a = 42 end
  end
  </code></pre>
  <p>That's fine. I think it is a powerful tool. But I found one limitation that makes me sad. It is impossible to include this module type into another one.</p>
  <pre><code>module EXTEND_S (CONTAINER : sig module type S end) = struct
    module type S = sig
      include CONTAINER.S
      val extention : int
    end
  end
  </code></pre>
  <p>Or</p>
  <pre><code>module AS_PART_OF_IMPL (CONTAINER : sig module type S end) = struct
    module type S = sig
      module Impl : sig
        include CONTAINER.S
        val extention : int
      end 
    end 
  end
  </code></pre>
  <blockquote>
  <p><code>include CONTAINER.S</code><br />
  <code>        ^^^^^^^^^^^</code><br />
  Error: This module type is not a signature</p>
  </blockquote>
  <p>Why I can't do this? For me, it looks like some gap, nor only in the compiler but in language conception too. What I miss to understand?</p>