Created
July 13, 2020 05:06
-
-
Save Jason5Lee/f7fe9c803a5f244833a81d10f1530a95 to your computer and use it in GitHub Desktop.
Haskell helloworld example of asynchronous IO.
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 Control.Concurrent.Async | |
delayHello n = do | |
threadDelay (n * 100) | |
let hello = show n ++ ": Hello World!" | |
putStrLn hello | |
delayHello :: Int -> IO () | |
delayHello n = do | |
threadDelay (n * 100) | |
let hello = show n ++ ": Hello World!" | |
putStrLn hello | |
main :: IO () | |
main = sequence_ [delayHello i | i <- [0..1000]] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment