Skip to content

Instantly share code, notes, and snippets.

@Jason5Lee
Created July 13, 2020 05:06
Show Gist options
  • Save Jason5Lee/f7fe9c803a5f244833a81d10f1530a95 to your computer and use it in GitHub Desktop.
Save Jason5Lee/f7fe9c803a5f244833a81d10f1530a95 to your computer and use it in GitHub Desktop.
Haskell helloworld example of asynchronous IO.
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