title: Parallel processing in F#
body: <p>I'm playing around with <code>async</code> in F#. Does this look right, or am I mangling things?</p>
  
  <pre><code>let time f = 
      let before = System.DateTime.Now
      f () |&gt; ignore
      let after = System.DateTime.Now
      after - before;;
  
  let rec fib = function 0 | 1 -&gt; 1
                           | n -&gt; fib (n - 1) + fib (n - 2);;
  
  let source = [45; 40; 45; 40]
  
  let synchronous = time &lt;| fun () -&gt; List.map fib source
  
  let para = time &lt;| fun () -&gt; source
                               |&gt; List.map (fun n -&gt; async {ignore &lt;| fib n}) 
                               |&gt; Async.Parallel
                               |&gt; Async.RunSynchronously
  </code></pre>
  
  <p>In particular, how do I return results from an <code>async</code> block? Do I have to use mutable state?</p>
  
  <p><strong>Update:</strong> here's another approach:</p>
  
  <pre><code>#r "FSharp.PowerPack.Parallel.Seq.dll"
  open Microsoft.FSharp.Collections
  
  let pseq = time &lt;| fun () -&gt; source
                               |&gt; PSeq.map fib
                               |&gt; PSeq.toList
  </code></pre>