Create a gist now

Instantly share code, notes, and snippets.

@yuntan /chan1.hs
Last active Dec 3, 2015

What would you like to do?
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