Last active
December 3, 2015 04:14
-
-
Save yuntan/d4cd59cfc7d03c6ce8f6 to your computer and use it in GitHub Desktop.
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 (forkIO, threadDelay) | |
import Control.Concurrent.Chan (newChan, readChan) | |
import Control.Monad (forever) | |
every :: Int -> IO a -> IO () | |
every time io = forever $ do | |
threadDelay (time * 1000000) | |
io | |
main :: IO () | |
main = do | |
_ <- forkIO $ every 3 $ putStrLn "3" | |
_ <- forkIO $ every 5 $ putStrLn "5" | |
newChan >>= readChan |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment