<p><br>
On Jun 8, 2012 11:37 AM, &quot;Simon Marlow&quot; &lt;<a href="mailto:marlowsd@gmail.com">marlowsd@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt; I&#39;d like to add a higher-level concurrency API to the base package. This API has grown while I&#39;ve been working on examples for my book, and I&#39;m convinced that we should have something like this in the standard libraries.  Here&#39;s the API I propose:<br>

&gt;<br>
&gt; <a href="http://community.haskell.org/~simonmar/async-stm/Control-Concurrent-Async.html">http://community.haskell.org/~simonmar/async-stm/Control-Concurrent-Async.html</a><br>
&gt;<br>
&gt; In fact it already exists in at least two packages on Hackage: &#39;async&#39; and &#39;threads&#39;.  My version is a superset of both of these, except for a few small differences (which are up for discussion, of course).<br>

&gt;<br>
&gt; One good reason to have this package is that it avoids some common pitfalls, such as forgetting to handle exceptions in your child threads.  In the Async API, you get to choose whether to (a) receive the result as &#39;Either SomeException a&#39;, or (b) have the exception re-thrown in the waiting thread.  You don&#39;t get to ignore it altogether.<br>

&gt;<br>
&gt; Another common pitfall avoided by this library is accidentally leaving threads running in the background.  This is handled by withAsync:<br>
&gt;<br>
&gt;  withAsync :: IO a -&gt; (Async a -&gt; IO b) -&gt; IO b<br>
&gt;<br>
&gt; the child thread is always cancelled (i.e. killed) when the second argument returns or throws an exception, if it hasn&#39;t finished already.<br>
&gt;<br>
&gt;<br>
&gt; I&#39;m opening this up for discussion so that we can tidy up any inconsistent details and add any functions that people feel are missing.  Naming is obviously up for discussion too.<br>
&gt;<br>
&gt; Cheers,<br>
&gt;        Simon<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Libraries mailing list<br>
&gt; <a href="mailto:Libraries@haskell.org">Libraries@haskell.org</a><br>
&gt; <a href="http://www.haskell.org/mailman/listinfo/libraries">http://www.haskell.org/mailman/listinfo/libraries</a></p>
<p>What&#39;s the advantage to putting this in base instead of a separate package? If it goes in base, it will make it more difficult to upgrade, and take longer for this module to be adopted at all. If possible, I&#39;d opt for a standalone package.</p>

<p>Michael</p>