-- Public Types ---------------------------------------------------------------
-- Semi-Public Types ----------------------------------------------------------
-- Public Functions -----------------------------------------------------------


{- |
  Like `sequence`, but all io operations are executed concurrently.
-}
concurrently :: [IO a] -> IO [a]
concurrently ios = do
  jobs <- mapM async ios
  results <- mapM takeMVar jobs
  case sequence results of
    Right vals -> return vals
    Left err -> throw err


{- |
  Like `sequence_`, but all io operations are executed concurrently.
-}
concurrently :: [IO a] -> IO [a]
concurrently ios = do
  jobs <- mapM async ios
  results <- mapM takeMVar jobs
  case sequence results of
    Right vals -> return vals
    Left err -> throw err


{- |
  Like `sequence_`, but all io operations are executed concurrently.
-}
concurrently ios = do
  jobs <- mapM async ios
  results <- mapM takeMVar jobs
  case sequence results of
    Right vals -> return vals
    Left err -> throw err


{- |
  Like `sequence_`, but all io operations are executed concurrently.
-}