<div dir="ltr"><div><div><div><div><div><div><div>Hi,<br><br></div>First of all, apologies if this is not the right place to ask this question.<br><br></div>I'm reading the book "Parallel and concurrent programming in Haskell" and I'm having some issues reasoning about the impact of laziness.<br><br></div>Looking at the first example in chapter 8 [1] <br><br>main = do<br>  m1 <- newEmptyMVar                                   <br>  m2 <- newEmptyMVar                               <br><br>  forkIO $ do                                         <br>    r <- getURL "<a href="http://www.wikipedia.org/wiki/Shovel">http://www.wikipedia.org/wiki/Shovel</a>"<br>    putMVar m1 r<br><br>  forkIO $ do                                  <br>    r <- getURL "<a href="http://www.wikipedia.org/wiki/Spade">http://www.wikipedia.org/wiki/Spade</a>"<br>    putMVar m2 r<br><br>  r1 <- takeMVar m1                         <br>  r2 <- takeMVar m2                                   <br>  print (B.length r1, B.length r2)                 <br><br></div>I don't understand why this function is not just putting an unevaluated thunk in the MVar. Well, I assume that getURL is an eager function, but looking at its code [2] or at the documentation of Network.Browser [3] I don't see why...<br><br></div>Am I looking at this wrong? Is there any rule of thumb to be used in these cases? I have the impression that it's really easy to end up creating thunks in parallel threads and evaluating them in the main one...<br><br></div>Thanks,<br></div>Jose.<br><div><div><div><div><br>[1] <a href="http://chimera.labs.oreilly.com/books/1230000000929/ch08.html">http://chimera.labs.oreilly.com/books/1230000000929/ch08.html</a><br>[2] <a href="https://github.com/simonmar/parconc-examples/blob/master/GetURL.hs">https://github.com/simonmar/parconc-examples/blob/master/GetURL.hs</a><br>[3] <a href="http://hackage.haskell.org/package/HTTP-4000.0.8/docs/Network-Browser.html">http://hackage.haskell.org/package/HTTP-4000.0.8/docs/Network-Browser.html</a><br><br></div></div></div></div></div>