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

Patrick Caldon patc at pessce.net
Fri Dec 4 06:51:10 EST 2009


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.

I'm looking for a concurrency library with something like:

forkSequence :: Int -> [IO a] -> IO [a]

which I could call with something like this:

forkSequence 4 (take 10 (repeat  (runWorldSim g ss)))

this would construct 4 threads, then dispatch the 10 jobs onto the 
threads, and pack up the
results into a list I could run through my merger.

It strikes me as something someone would already have done, but I can't 
find anything in hackage.  Probably I've missed something obvious?  Any 
pointers?

If not, what would be the best/easiest existing package to write an 
extension to?

Thanks,
Patrick.




More information about the Haskell-Cafe mailing list