title: What data structure should I use to hold a collection of functions in F#
body: <p>Some features of the data structure worth mentioning:
  1. The functions will NOT all have the same signatures (my main issue)
  2. The data structure does not have to be immutable</p>
  
  <p>I'm comfortable with all the main vanilla data structures, my concern is around what "generalized type" is the best umbrella type to represent a function in such a collection of functions. In particular, is their anything better than just boxing them as obj / System.Object?</p>
  
  <p>When the function is being "packed" into the data structure I will know it's signature. This can be stored in some way and linked to this function such that it can be used to "unpack" the function into the correct form when it is needed.</p>
  
  <p>I am assuming that I can create function signature types and store them in a collection of their own - perhaps this is a bad assumption though? In other words:</p>
  
  <pre><code>let f1: float-&gt; float
  let f2: string-&gt;bool-&gt;float
  </code></pre>
  
  <p>Can the <code>typeof(f1)</code> and <code>typeof(f2)</code> be stored in the same data structure. I would think that since they are both of type <code>Type</code> this should be possible</p>
  
  <p>In reply to the comment below by @ildjarn: The expected signatures could be any 1-5 input parameter combinations of the usual suspects like float, string, bool, date and with the result parameter varying equally over float | string | bool. </p>
  
  <p>Taking the above into account, how best can the functions be stored for later retrieval and application (partial or full) and or composition with other functions.</p>
  
  <h1>EDIT</h1>
  
  <p>The simplest approach I can come up with is the following:</p>
  
  <pre><code>let f1 x = exp x
  let t1 = f1.GetType()
  let o1 = box f1 // alternate syntax
  let f11 = o1 :?&gt; t1 // ?? FAILS HERE!!!!!
  f11 3.0
  </code></pre>
  
  <p>But I don't know how to downcast from the object back to the function type I had prior to boxing.</p>