module Parallel (parMapM, parSequence) where import Control.Concurrent.ParallelIO.Local (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) parSequence :: [IO a] -> IO [a] parSequence xs = do n <- getNumProcessors withPool n $ \pool -> parallel pool xs