title: Arithmetic casting to generic type in F#
body: <p>I try to write a function which does a generic casting for arithmetic types, for example a function which receives an argument of type <code>uint64</code>, then converts to a type being the same as the type parameter. My idea is:</p>
  
  <pre><code>let convert&lt;'T&gt; (x:uint64) = 'T x
  </code></pre>
  
  <p>But this code does not compile, and I stuck here after trying several approaches like:</p>
  
  <pre><code>let convert&lt;'T&gt; (x:uint64) = 
    match Unchecked.defaultof&lt;'T&gt; with 
      | :? uint32 -&gt; uint32 x
  ....
  </code></pre>
  
  <p>So how could I write such a generic arithmetic casting in F#? (I just start learning so my question is maybe stupid, please take it easy).</p>