title: Combine a list of functions into a single function using fold
body: <p>Lets say I have a list of functions</p>
  
  <pre><code>let plus_one (x: int) : int = x + 1 in
  let double (x: int) : int = x * 2 in
  let square (x: int) : int = x * x in
  let fun_list = [square, double, plus_one] ;;
  </code></pre>
  
  <p>Using fold, I want to take this list of functions and combine them into a single function. Something like,</p>
  
  <pre><code>let combined (x: int) : int = x * (2 * (x + 1))
  </code></pre>
  
  <p>This is what I have: </p>
  
  <pre><code>let combine_functions (fun_list : ('a -&gt; 'a) list) : ('a -&gt; 'a) =
      List.fold_right (fun f acc -&gt; f acc) fun_list (fun x -&gt; x)
  ;;
  </code></pre>
  
  <p>I would think this would work, however when I try to run this, it tells me that this expression has type 'a -> 'a when it should have type ('a -> 'a) -> ('a -> 'a)</p>