Skip to content

Instantly share code, notes, and snippets.

@yuntan
Last active December 3, 2015 04:14
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 yuntan/d4cd59cfc7d03c6ce8f6 to your computer and use it in GitHub Desktop.
Save yuntan/d4cd59cfc7d03c6ce8f6 to your computer and use it in GitHub Desktop.
Haskellで定期実行
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