Created
          April 19, 2017 17:00 
        
      - 
      
 - 
        
Save gnull/1099a991da6ddc769a16619a0912cc9f to your computer and use it in GitHub Desktop.  
    Haskell lazy async
  
        
  
    
      This file contains hidden or 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.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