title: ocaml when reading the book by Jason Hickey
body: <p>For the final rule, explicit annotation for higher-order functions, consider the following definition of a function apply.</p>
  
  <pre><code># let apply g = g ~x:1 2 + 3;;  
  val apply : (x:int -&gt; int -&gt; int) -&gt; int = &lt;fun&gt;
  </code></pre>
  
  <p>I do not understand the above line and thus the following stuff:</p>
  
  <p>Note that the compiler infers that the function <code>~g</code> has a labeled, not an optional argument. The syntax <code>g ~x:1</code> is the same, regardless of whether the label <code>x</code> is labeled or optional, but the two are not the same.</p>
  
  <pre><code># apply (fun ?(x = 0) y -&gt; x + y);; Characters 6-31:
  apply (fun ?(x = 0) y -&gt; x + y);; ^^^^^^^^^^^^^^^^^^^^^^^^^
  </code></pre>
  
  <p>This function should have type <code>x:int -&gt; int -&gt; int</code> but its first argument is labeled <code>~?x</code></p>
  
  <p>The compiler will always prefer to infer that an argument is labeled, not optional. If you want the other behavior, you can specify the type explicitly.</p>
  
  <pre><code># let apply (g : ?x:int -&gt; int -&gt; int) = g ~x:1 2 + 3;; val apply : (?x:int -&gt; int -&gt; int) -&gt; int = &lt;fun&gt;
  # apply (fun ?(x = 0) y -&gt; x + y);;
  - : int = 6
  </code></pre>
  
  <p>Is there anyone able to help?</p>