title: Explanation for the implicit argument in my Ocaml code
body: <p>I don't understand the following OCaml code as I am not sure how the <strong>extract_ident</strong> function infers that the unary parameter is <strong>string_lexer</strong> when it does not explicitly specify it and how it's passed into <strong>extract</strong>. I understand that you can have a function without the <strong>match</strong> construct and the type in the pattern matching is the last argument, but I don't understand how <strong>string_lexer</strong> argument is passed into <strong>extract</strong> implicitly?</p>
  
  <pre><code>type string_lexer = {string:string; mutable current:int; size:int } ;;
  
  let init_lex s = {string=s, current=0; size=String.length s} ;;
  let forward cl = cl.current &lt;- cl.current+1 ;;
  let forward_n cl n = cl.current &lt;- cl.current+n ;;
  let extract pred cl =
      let st = cl.string and pos = cl.current in
      let rec ext n = if n&lt;cl.size &amp;&amp; (pred st.[n]) then ext (n+1) else n in
      let res = ext pos in
      cl.current &lt;- res; String.sub cl.string pos (res-pos) ;;
  
  let extract_int =
      let is_int = function '0'..'9' -&gt; true | _ -&gt; false
      in function cl -&gt; int_of_string (extract is_int cl);;
  
  let extract_ident =
      let is_alpha_num = function
          'a'..'z' | 'A'..'Z' | '0'..'9' | '_' -&gt; true
          | _ -&gt; false
      in extract is_alpha_num ;;
  </code></pre>