title: F# function return several types (return kind of generic object type)?
body: <p>I keep learning F# pattern matching with my simple function which should return square root if argument is number, argument otherwise. I've modified it a bit and it looks like as follows.</p>
  
  <pre><code>let my_sqrt (o: obj) =
    match o with
    | :? float as d -&gt; (sqrt d).ToString()
    | _ as x -&gt; x.ToString()
  </code></pre>
  
  <p>It is working fine for my purpose, but what if I don't want to cast return value to string? How can I return "some object" and then use it in <code>printfn "%A" (my_sqrt [| 1; 2; 3 |])</code> construction?</p>