@@ -17,6 +17,7 @@ module Asyncly.RunAsync
17 , runAsyncly
17 , runAsyncly
20 , runAsynclyRecorded
21 , runAsynclyRecorded
21-- , toListRecorded
22-- , toListRecorded
22 , playRecordings
23 , playRecordings
@@ -30,6 +31,7 @@ import Control.Monad.Catch (MonadThrow)
30import Control.Monad.IO.Class (MonadIO (..))
31import Control.Monad.IO.Class (MonadIO (..))
31import Control.Monad.Trans.Class (MonadTrans (lift))
32import Control.Monad.Trans.Class (MonadTrans (lift))
32import Control.Monad.State (StateT(..), runStateT)
33import Control.Monad.State (StateT(..), runStateT)
34+import Data.Monoid ((<>))
33import Data.IORef (IORef, newIORef, readIORef)
35import Data.IORef (IORef, newIORef, readIORef)
35import Control.Monad.Trans.Recorder (MonadRecorder(..), RecorderT,
37import Control.Monad.Trans.Recorder (MonadRecorder(..), RecorderT,
@@ -104,9 +106,15 @@ toList m = run Nothing m
104 {-# INLINE run #-}
106 {-# INLINE run #-}
105 run ctx mx = (runAsyncT mx) ctx stop yield
107 run ctx mx = (runAsyncT mx) ctx stop yield
109+-- | Run a given function concurrently on the list and collect the results.
110+{-# INLINABLE for #-}
111+for :: MonadAsync m => [a] -> (a -> AsyncT m b) -> AsynclyT m b
112+for xs f = foldr (<|>) empty $ map f xs
114+-- XXX rename to fromList?
107{-# INLINABLE each #-}
115{-# INLINABLE each #-}
108each :: MonadAsync m => [a] -> AsynclyT m a
116each :: MonadAsync m => [a] -> AsynclyT m a
109−each xs = foldr (<|>) empty $ map return xs
117+each xs = foldr (<>) empty $ map return xs
111------------------------------------------------------------------------------
119------------------------------------------------------------------------------
112-- Logging
120-- Logging