title: Why can't OCaml infer the following type:
body: <p>Consider the following code</p>
  
  <pre><code>module type Foo = sig 
    type t
    val do_with_t : t -&gt; unit
  end
  
  let any_foo t (module F : Foo) = F.do_with_t t
  </code></pre>
  
  <p>Which is rejected with the following lovely type error:</p>
  
  <pre><code>Error: This expression has type F.t but an expression was expected of type F.t
        The type constructor F.t would escape its scope
  </code></pre>
  
  <p>But is accepted once I add the following type annotion:</p>
  
  <pre><code>let any_foo (type s) (t:s) (module F : Foo with type t = s) = F.do_with_t t
  </code></pre>
  
  <p>The sharing constraint makes sense to me so my question is why can't OCaml infer the type signature from my usage of <code>t</code> inside the function.</p>