title: How to add instances of sub types that have common base class to the same list in FSharp?
body: <p>I have a base abstract class named <code>Token</code>and some sub types like <code>NumToken</code>,<code>StrToken</code>.<br>
  I want to put their instances to the same list.  </p>
  
  <p>I can't declare a variable use <code>let l = list&lt;'a when 'a :&gt; Token&gt;</code>  </p>
  
  <p>Then, I write  </p>
  
  <pre><code>    let extractToken&lt;'a when 'a :&gt; Token&gt;(lineNum:int, line:string) : 'a list option =
          let mutable result : 'a list = []  
  </code></pre>
  
  <p>It works, but can not add element.<code>result &lt;- new NumToken(lineNum, value) :: result</code> just say it needs <code>'a</code> but here is <code>NumToken</code>  </p>
  
  <p>Now I can use <code>new NumToken(lineNum, value) :&gt; Token</code> and declare <code>Token list</code>.<br>
  It wokrs but looks ugly(I know fsharp doesn't do auto up cast..).  </p>
  
  <p><code>list&lt;_ :&gt; Token&gt;</code> doesn't work too, it only accepts one sub type.  </p>
  
  <p>Thx for help.</p>