Created
July 16, 2013 02:00
-
-
Save egonSchiele/6005209 to your computer and use it in GitHub Desktop.
Drawing timer in Haskell
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
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: ./Timer 5