gang-of-threads-3.2.1: Non-deterministic parallelism with bags

Safe HaskellSafe-Inferred



A monad transformer implementation for processing the results of a bag of tasks computation. Using a processor based on the BagT transformer allows the calculation of values to be aborted immediately after running the processor.

This can be use by some of the bag of tasks interfaces such as Control.Concurrent.Bag.Safe and Control.Concurrent.Bag.SafeConcurrent.



newtype BagT r m a Source

A monad transformer for processing the results of the bag sequencially. In addition to the actions available in the base monad, which has to be an instance of MonadIO in all functions, it provides the action getResult to get a result of the bag.




getBagReader :: ReaderT (m (Maybe r)) m a


MonadTrans (BagT r) 
Monad m => Monad (BagT r m) 
Monad m => Functor (BagT r m) 
Monad m => Applicative (BagT r m) 
MonadIO m => MonadIO (BagT r m) 

getResult :: MonadIO m => BagT r m (Maybe r)Source

Get a result of the bag if there is one. If it returns Nothing, all tasks have been processed and there are no results left. getResults blocks until a task has been evaluated to a result or all tasks are processed. Therefore it may block forever.

getAllResults :: MonadIO m => BagT a m [a]Source

Convenience function to get all results from the bag of tasks.