Skip to content

Instantly share code, notes, and snippets.

View tinco's full-sized avatar

Tinco Andringa tinco

View GitHub Profile
@tinco
tinco / concurrent_sieve.hs
Created November 18, 2012 15:39 — forked from tmhedberg/concurrent_sieve.hs
Concurrent prime sieve translated from Go (http://play.golang.org/p/9U22NfrXeq)
-- 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 ()