Hoogle Search
Within LTS Haskell 24.51 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
pooledMapConcurrentlyIO :: Traversable t => Int -> (a -> IO b) -> t a -> IO (t b)unliftio UnliftIO.Internals.Async No documentation available.
pooledMapConcurrentlyIO' :: Traversable t => Int -> (a -> IO b) -> t a -> IO (t b)unliftio UnliftIO.Internals.Async No documentation available.
pooledMapConcurrentlyIO_ :: Foldable t => Int -> (a -> IO b) -> t a -> IO ()unliftio UnliftIO.Internals.Async No documentation available.
pooledMapConcurrentlyIO_' :: Foldable t => Int -> (a -> IO ()) -> t a -> IO ()unliftio UnliftIO.Internals.Async No documentation available.
pooledMapConcurrentlyN :: (MonadUnliftIO m, Traversable t) => Int -> (a -> m b) -> t a -> m (t b)unliftio UnliftIO.Internals.Async Like mapConcurrently from async, but instead of one thread per element, it does pooling from a set of threads. This is useful in scenarios where resource consumption is bounded and for use cases where too many concurrent tasks aren't allowed.
Example usage
import Say action :: Int -> IO Int action n = do tid <- myThreadId sayString $ show tid threadDelay (2 * 10^6) -- 2 seconds return n main :: IO () main = do yx <- pooledMapConcurrentlyN 5 (\x -> action x) [1..5] print yx
On executing you can see that five threads have been spawned:$ ./pool ThreadId 36 ThreadId 38 ThreadId 40 ThreadId 42 ThreadId 44 [1,2,3,4,5]
Let's modify the above program such that there are less threads than the number of items in the list:import Say action :: Int -> IO Int action n = do tid <- myThreadId sayString $ show tid threadDelay (2 * 10^6) -- 2 seconds return n main :: IO () main = do yx <- pooledMapConcurrentlyN 3 (\x -> action x) [1..5] print yx
On executing you can see that only three threads are active totally:$ ./pool ThreadId 35 ThreadId 37 ThreadId 39 ThreadId 35 ThreadId 39 [1,2,3,4,5]
pooledMapConcurrentlyN_ :: (MonadUnliftIO m, Foldable f) => Int -> (a -> m b) -> f a -> m ()unliftio UnliftIO.Internals.Async Like pooledMapConcurrentlyN but with the return value discarded.
pooledMapConcurrently_ :: (MonadUnliftIO m, Foldable f) => (a -> m b) -> f a -> m ()unliftio UnliftIO.Internals.Async Like pooledMapConcurrently but with the return value discarded.
bmap :: FunctorB b => (forall (a :: k) . () => f a -> g a) -> b f -> b ghedgehog Hedgehog No documentation available.
bmap :: FunctorB b => (forall (a :: k) . () => f a -> g a) -> b f -> b ghedgehog Hedgehog.Internal.Barbie No documentation available.
concatMap :: Foldable t => (a -> [b]) -> t a -> [b]hedgehog Hedgehog.Internal.Prelude Map a function over all the elements of a container and concatenate the resulting lists.
Examples
Basic usage:>>> concatMap (take 3) [[1..], [10..], [100..], [1000..]] [1,2,3,10,11,12,100,101,102,1000,1001,1002]
>>> concatMap (take 3) (Just [1..]) [1,2,3]