Created
November 22, 2021 15:10
-
-
Save kayvank/3deae4f41375efdf940a15fe77fefb4d to your computer and use it in GitHub Desktop.
Example of Symmetric Concurrency Combinators from Parallel concurrent programming in Haskell
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
#!/usr/bin/env stack | |
{- | |
stack | |
--resolver lts-17.13 runghc | |
--package http-conduit | |
--package async | |
-} | |
-- | |
-- | |
import Control.Concurrent | |
import Control.Concurrent.STM | |
import Control.Concurrent.Async | |
import Control.Exception | |
import qualified Data.ByteString.Lazy as LB | |
import Network.HTTP.Conduit | |
import Text.Printf | |
url1, url2 :: String | |
(url1, url2) = ("http://www.wikipedia.org/wiki/Shovel" , "http://www.wikipedia.org/wiki/Spade") | |
main :: IO () | |
main = do | |
(r1, r2) <- concurrently(simpleHttp url1) (simpleHttp url2) | |
print (LB.length r1, LB.length r2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment