title: Is there a safe way of converting a Collection to a sequence in F#?
body: <p>Good afternoon, all!</p>
  
  <p>So I've been playing around with ways of casting a .NET Collection to a functional data structure. The best I've been able to get is to cast it to a seq first and to whatever I want after that.</p>
  
  <p>The problem is that this seems to break type inference, which is obviously unsafe. </p>
  
  <p>Example:</p>
  
  <pre><code>let a = new System.DirectoryServices.DirectorySearcher("&lt;query&gt;") in
  let entries = a.FindAll ()
  let entries_list = 
       let (entries_seq : seq&lt;obj&gt;) = Seq.cast entries_list in
       Seq.toList entries_Seq
  in
  entries_list (* list of AD objects found from query, has type obj *)
  </code></pre>
  
  <p>In order to do anything useful with entries_list, I'd have to do:</p>
  
  <pre><code>entries_list :?&gt; SearchResult
  </code></pre>
  
  <p>Trying to generalise it to a seq&lt;'a> fails, since the compiler still requires that I statically type its enumerator (which makes sense).</p>
  
  <p>Is there any way of avoiding this? I'm starting to think this is a limitation of using .NET data structures in a functional manner.</p>
  
  <p>Sorry if this is a novice question; I'm green to F# and functional programming in general (and am loving it!). Cheers!</p>
  
  <ul>
  <li>Carlos.</li>
  </ul>