Skip to content

Instantly share code, notes, and snippets.

@gnull
Created April 19, 2017 17:00
Show Gist options
  • Save gnull/1099a991da6ddc769a16619a0912cc9f to your computer and use it in GitHub Desktop.
Save gnull/1099a991da6ddc769a16619a0912cc9f to your computer and use it in GitHub Desktop.
Haskell lazy async
import Control.Concurrent.Async
import Control.Monad
sites = ["http://www.google.com",
"http://www.bing.com",
"http://www.yahoo.com",
"http://www.wikipedia.com/wiki/Spade",
"http://www.wikipedia.com/wiki/Shovel"]
printRepeat :: String -> IO [String]
printRepeat url = do
return $ repeat url
main = do
as <- mapM (async . printRepeat) sites
xs <- mapM wait as
forM_ xs $ putStrLn . ("Got: " ++) . head
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment