Created
May 12, 2010 15:33
-
-
Save rrichardson/398727 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
forMpar :: [a] -> (a -> IO b) -> IO [b] | |
forMpar xs fun = do | |
sem <- newQSem (length xs) | |
c <- newChan | |
forM_ xs (\x -> forkIO $ wrap fun x c sem) | |
waitQSem sem | |
collect (length xs) c [] | |
where wrap f item chan qsem = f item >>= writeChan chan >> signalQSem qsem | |
collect 0 chan acc = return acc | |
collect count chan acc = do !i <- readChan chan; collect (count - 1) chan i::acc | |
Network/BsonRPC/Util.hs:95:0: | |
Occurs check: cannot construct the infinite type: b = [b] | |
When generalising the type(s) for `forMpar' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment