Skip to content

Instantly share code, notes, and snippets.

@dvdsgl
Created August 15, 2013 18:15
Show Gist options
  • Save dvdsgl/6243245 to your computer and use it in GitHub Desktop.
Save dvdsgl/6243245 to your computer and use it in GitHub Desktop.
A $12 million Haskell program.
import System.Exit
import Control.Monad
import Control.Concurrent
import Control.Concurrent.MVar
main = do
currentPos <- newMVar (1, 2)
forkIO $ forever $ do
(x, y) <- readMVar currentPos
when (x + 1 /= y) $ do
putStrLn $ show x ++ " " ++ show y
exitFailure
-- Update forever
forever $ do
(x, y) <- takeMVar currentPos
putMVar currentPos (x + 1, y + 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment