import Control.Concurrent.Bag.Basic import Control.Concurrent (threadDelay) import Control.Concurrent.STM.TStack import Fib import System.Mem import Control.DeepSeq f i = (fib i) : f (i+1) main :: IO () main = do bag <- newBag_ Nothing :: IO (Bag TStack [Int]) addTask bag $ return $ Just [] addTask bag $ let r = f 0 in r `deepseq` return $ Just r getResult bag >>= putStrLn . show terminateBag bag threadDelay 10000000