Proposal: Control.Concurrent.Async

Simon Marlow marlowsd at
Fri Jun 15 17:22:40 CEST 2012

On 15/06/2012 15:42, Twan van Laarhoven wrote:
> On 15/06/12 15:38, Simon Marlow wrote:
>> On 15/06/2012 13:52, Twan van Laarhoven wrote:
>>> On 08/06/12 10:37, Simon Marlow wrote:
>> monad-par is for pure deterministic parallelism only, since it is
>> based around
>> runPar :: Par a -> a
>> So I'm slightly confused by your comment that it can be used for IO as
>> well -
>> what do you mean exactly?
> I base this on the documentation of Control.Monad.Par.Unsafe:
> unsafeParIO :: IO a -> p a
> Lift an IO operation into the Par monad.
> These are unsafe (in the normal, Haskell sense) when used with a runPar
> of type `Par a -> a`. If used with a runParIO that stays in the IO
> monad, then they are simply dangerous.

Ah, so runParIO is part of meta-par, not monad-par as such.  There is no 
instance of ParUnsafe for the default monad-par scheduler.

You have a point that with runParIO, meta-par is similar to Async.
However, the goals are quite different: meta-par is aimed at parallel 
throughput rather than concurrency, so you don't necessarily get 
preemption and fairness like you do with forkIO and Async.  If you do 
blocking IO inside unsafeParIO, it is likely that you'll block other 
threads, because meta-par is doing its own scheduling.  So while you 
*can* do IO operations inside the Par monad, the reason is to allow 
nondeterministic parallel computations, rather than true concurrency.


More information about the Libraries mailing list