A parallel monad map in Haskell? Something like parMapM?
haskell, monads, parallel-processing, state-monad
Solution
First of all, by just two words out of your question: parallel and array - I must recommend you to take a look at repa. Also you should check out Data Parallel Haskell, as it promises to be a next huge milestone on the Haskell's road and there are some great people involved with this project.
Concerning your specific question, there are libraries able to do exactly what you ask for, just with an `IO` monad, the already named monad-parallel and async with `mapConcurrently`. Have you considered using `stToIO` to escape into `IO`?
There's also a lifted-async library, which expands the standard version to work with `MonadBaseControl`, which has an instance of `ST`, so you can probably use its version of `mapConcurrently` or at least use it as an inspiration to implement your own.
Problem
I'm looking for a way to run two computations in parallel in the ST-Monad. I am building a rather large array (using STUArray) and I would like to do it in parallel. So far I've found this and this Q&A here on stackoverflow, however the first does not apply in my case, as it deals with pure code only and the second deals with the IO monad - but I am in a State Thread. I've also found the monad-parallel package, but it requires me to have an instance of 'MonadParallel' for ST. Also the monad-par package does support only pure computations or the IO monad. Is there a way to do a parallel monadic computation inside ST ?