parallelTraverse :: (a -> IO b) -> [a] -> IO [b]
parallelTraverse f xs = sequence =<< mapM spawn xs where
  spawn a = do
    r <- MVar.newEmptyMVar
    _ <- CC.forkIO $ f a >>= \b -> MVar.putMVar r b
    pure (MVar.takeMVar r)
parallelTraverse :: (a -> IO b) -> [a] -> IO [b]
parallelTraverse f xs = sequence =<< mapM spawn xs where
  spawn a = do
    r <- MVar.newEmptyMVar
    _ <- CC.forkIO $ f a >>= \b -> MVar.putMVar r b
    pure (MVar.takeMVar r)
parallelTraverse f xs = sequence =<< mapM spawn xs where
  spawn a = do
    r <- MVar.newEmptyMVar
    _ <- CC.forkIO $ f a >>= \b -> MVar.putMVar r b
    pure (MVar.takeMVar r)