Skip to content

Instantly share code, notes, and snippets.

@egonSchiele
Created July 16, 2013 02:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save egonSchiele/6005209 to your computer and use it in GitHub Desktop.
Save egonSchiele/6005209 to your computer and use it in GitHub Desktop.
Drawing timer in Haskell
import Control.Concurrent
import System.Process
import System.Environment
say str = system $ "say '" ++ str ++ "'"
timer :: Int -> IO ()
timer 1 = do
say "one minute left! oh crap!"
threadDelay $ 30 * 1000 * 1000
say "thirty seconds left!!!"
threadDelay $ 30 * 1000 * 1000
say "time is up!"
putStrLn "\a"
timer m = do
say $ show m ++ " minutes left"
threadDelay $ 60 * 1000 * 1000
timer (m - 1)
main = do
say "starting timer"
threadDelay $ 4 * 1000 * 1000
getArgs >>= timer . read . head
@egonSchiele
Copy link
Author

Usage: ./Timer 5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment