[Haskell-cafe] You are in a twisty maze of concurrency libraries, all different ...

Paul Johnson paul at cogito.org.uk
Fri Dec 4 14:23:29 EST 2009

On 04/12/09 11:51, Patrick Caldon wrote:
> I'm looking for the "right" concurrency library/semantics for what 
> should be a reasonably simple problem.
> I have a little simulator:
> runWorldSim :: MTGen -> SimState -> IO SimState
> it takes about a second to run on a PC. It's functional except it 
> whacks the rng, which needs IO. I run 5-10 of these jobs, and then use:
> mergeWorld :: [SimState] -> SimState
> to pick the best features of the runs and build another possible world 
> (state).  Then I use this new world to run another 5-10 jobs and so 
> on.  I run this through ~20000 iterations.
> It's an obvious place for parallelism.
If you can get rid of the need for IO then you can use Control.Parallel 
to evaluate pure functions instead.  If you only use IO for the random 
numbers then you can either keep a StdGen in your SimState or else use a 
"State StdGen" monad.  Since your random number use is presumably 
already in monadic IO you could probably switch to a state monad fairly 


More information about the Haskell-Cafe mailing list