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
-- Compile with `ghc -threaded -with-rtsopts=-N concurrent_sieve.hs` | |
import Control.Concurrent | |
import Control.Monad | |
import System.Environment | |
-- Map over [2..] (2 until infinity), putting the value in mOut. The putting operation will block until | |
-- mOut is empty. mOut will become empty when some other thread executes takeMVar (getting its value). | |
generate :: MVar Int -> IO () |