Since the library you are using is not thread safe, you would like the solution to be based on using processes as an abstraction for parallelism. The example you would like to see with Par monad uses a parallelism model based on sparks or tasks, where many sparks can live in the same thread. Obviously, this is not what you are looking for.
Do not be afraid!
Haskell has several paradigms that work like this, and you mentioned one of them in your Cloud Haskell post. Although Cloud Haskell is not βmature,β it can solve your problems, but it can be a little heavyweight for your needs. If you just need to use many local cores using a parallel process-level abstraction, look at the Eden library:
http://www.mathematik.uni-marburg.de/~eden/
With Eden, you can absolutely express what you need. Here is a very simple example according to your version based on Par Monad:
f $
Or in the case of many arguments, you can simply pull out a map of the old:
map f $# args
For more information on $ # syntax and tutorials about Eden, see:
http://www.mathematik.uni-marburg.de/~eden/paper/edenCEFP.pdf
YMMV, since most of the more mature parallel paradigms in Haskell suggest that you have a level of thread safety or that use can do parallel work in its purest form.
Good luck and happy hacking!
source share