title: OCaml passing labeled function as parameter / labeled function type equivalence
body: <p>Suppose a function <code>g</code> is defined as follows.</p>
  
  <pre><code>utop # let g ~y ~x = x + y ;;
  val g : y:int -&gt; x:int -&gt; int = &lt;fun&gt;
  utop # g ~x:1 ;;
  - : y:int -&gt; int = &lt;fun&gt;
  utop # g ~y:2 ;;
  - : x:int -&gt; int = &lt;fun&gt;
  utop # g ~x:1 ~y:2 ;;
  - : int = 3
  utop # g ~y:2 ~x:1 ;;
  - : int = 3
  </code></pre>
  
  <p>Now there is another function <code>foo</code></p>
  
  <pre><code>utop # let foobar (f: x:int -&gt; y:int -&gt; int) = f ~x:1 ~y:2 ;;
  val foobar : (x:int -&gt; y:int -&gt; int) -&gt; int = &lt;fun&gt;
  </code></pre>
  
  <p>Sadly when I try to provide <code>g</code> as the parameter of <code>foobar</code>, it complains:</p>
  
  <pre><code>utop # foobar g ;;
  Error: This expression has type y:int -&gt; x:int -&gt; int
         but an expression was expected of type x:int -&gt; y:int -&gt; int
  </code></pre>
  
  <p>This is quite surprising as I can successfully currify <code>g</code> but cannot pass it as the parameter.  I googled and found <a href="http://caml.inria.fr/pub/docs/u3-ocaml/ocaml051.html" rel="nofollow">this article</a> which doesn't help much.  I guess this is related to the underlying type system of OCaml (e.g. subtyping rules of labeled arrow types).</p>
  
  <p>So is it possible to pass <code>g</code> as the parameter to <code>foobar</code> by any means in OCaml?  If not, why is it not allowed?  Any supporting articles/books/papers would be sufficient.</p>