module Parallel (parMapM, parMapM_, parSequence) where import Control.Concurrent.ParallelIO.Local (parallel, parallel_, withPool) import GHC.Conc (getNumProcessors) parMapM :: (a -> IO b) -> [a] -> IO [b] parMapM f xs = do n <- getNumProcessors withPool n $ \pool -> parallel pool (map f xs) parMapM_ :: (a -> IO ()) -> [a] -> IO () parMapM_ f xs = do n <- getNumProcessors withPool n $ \pool -> parallel_ pool (map f xs) parSequence :: [IO a] -> IO [a] parSequence xs = do n <- getNumProcessors withPool n $ \pool -> parallel pool xs