<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>I use my nonblocking library:</p>
    <p>eg for IRC bot:</p>
    <p>   let myCallbacks = defaultCallbacks {<br>
                                      done_connected = binded,<br>
                                      done_reading = response_get tm ref
      stdgen gsref,<br>
                                      done_writing = response_written,<br>
                                      done_closed = \pl s -> do<br>
                                          putStrLn "peer closed,
      reconnecting"<br>
                                          s <- socket myCallbacks<br>
                                          connect pl s
      "83.140.172.212:6667"<br>
                                          return 1,<br>
                                      handle_error = \pl s buf len->
      do<br>
                                          str <- peekCStringLen
      (buf,fromIntegral len)<br>
                                          putStrLn $ "error "++str++",
      reconnecting"<br>
                                          s <- socket myCallbacks<br>
                                          connect pl s
      "83.140.172.212:6667"<br>
                                          return 1,<br>
                                      tick = binded_tick tm<br>
                                    }<br>
          s <- socket myCallbacks<br>
      <br>
          pl <- epoll 1000<br>
          connect pl s "83.140.172.212:6667"<br>
          run_loop pl (-1)<br>
      <br>
    </p>
    <div class="moz-cite-prefix">On 3/19/20 3:40 PM, Michael Hull wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CABzAe0YXf_wXek7ZKNcrUs4u3ooBtWKMw=0wdH32Kh20+sAhzA@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">Hi Niklas and Patrick,
        <div><br>
        </div>
        <div>Thankyou both for the comments -- this is what I am looking
          for. </div>
        <div><br>
        </div>
        <div>I have a follow-on question, if I have code like</div>
        <div><br>
        </div>
        getPages :: IO()<br>
        getPages = do (page1, page2, page3)<br>
             <- runConcurrently $ (,,)<br>
             <$> Concurrently (getURL "url1")<br>
             <*> Concurrently (getURL "url2")<br>
             <*> Concurrently (getURL "url3")
        <div><br>
        </div>
        <div>main :: IO()</div>
        <div>main = do </div>
        <div>    f <- async getPages</div>
        <div>    cancel f</div>
        <div><br>
        </div>
        <div>Am I guaranteed the the <font face="monospace">getURL()</font>
          calls will definitely have either finished, or cancel? (I
          looked through the source (<a
href="https://hackage.haskell.org/package/async-2.2.2/docs/src/Control.Concurrent.Async.html#Concurrently"
            moz-do-not-send="true">https://hackage.haskell.org/package/async-2.2.2/docs/src/Control.Concurrent.Async.html#Concurrently</a>),
          and I think so, because <font face="monospace">runConcurrently
          </font>is implemented in terms of <font face="monospace">race</font>,
          which is implemented using <font face="monospace">withAsync,
          </font><font face="arial, sans-serif">but I'm not confident
            with interpreting Haskell!)</font></div>
        <div><font face="arial, sans-serif"><br>
          </font></div>
        <div><font face="arial, sans-serif"><br>
          </font></div>
        <div><font face="arial, sans-serif">Many thanks,</font></div>
        <div><font face="arial, sans-serif"><br>
          </font></div>
        <div><font face="arial, sans-serif">Mike</font></div>
        <div><font face="arial, sans-serif"><br>
          </font></div>
        <div><br>
        </div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Wed, 18 Mar 2020 at 03:15,
          Niklas Hambüchen <<a href="mailto:mail@nh2.me"
            moz-do-not-send="true">mail@nh2.me</a>> wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px
          0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I've
          you're new to async, also check out my recent rework of the
          docs that talk about this topic specifically:<br>
          <br>
          <a href="https://github.com/simonmar/async/pull/105/files"
            rel="noreferrer" target="_blank" moz-do-not-send="true">https://github.com/simonmar/async/pull/105/files</a><br>
          <br>
          (To be available in the next release of async.)<br>
        </blockquote>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
<a class="moz-txt-link-freetext" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a>
Only members subscribed via the mailman list are allowed to post.</pre>
    </blockquote>
  </body>
</html>