Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You made a mistake when writing the <code>publisher</code> function:</p> <pre><code>foreverR $ do bs &lt;- await finallyF (ZMQ.close s M.&gt;&gt; ZMQ.term c M.&gt;&gt; print "ZMQ socket closed") $ do (liftU $ ZMQ.send s [] bs) (liftU (print "Sending message")) </code></pre> <p>You probably wanted to place the <code>finallyF</code> OUTSIDE the <code>foreverR</code> loop:</p> <pre><code>finallyF (...) $ foreverR $ do bs &lt;- await liftU $ ZMQ.send s [] bs) liftU (print "Sending message") </code></pre> <p>The way you wrote it, it finalizes after each send, so it's doing exactly what you told it to do: finalize after every send. <code>finallyF</code> calls the finalizer once the action it wraps is complete, both if it terminates successfully or unsuccessfully. You could also use <code>catchF</code> in that case, since the loop never terminates anyway:</p> <pre><code> catchF (...) $ foreverR $ do bs &lt;- await liftU $ ZMQ.send s [] bs) liftU (print "Sending message") </code></pre> <p>Alternatively, you could have kept it inside the loop but switched to <code>catchF</code> so that the finalizer doesn't get run after each send:</p> <pre><code>foreverR $ do bs &lt;- await catchF (ZMQ.close s M.&gt;&gt; ZMQ.term c M.&gt;&gt; print "ZMQ socket closed") $ do (liftU $ ZMQ.send s [] bs) (liftU (print "Sending message")) </code></pre> <p>Also, if you are planning on writing a zeroMQ library based on pipes, keep in touch with me because I'm planning to return frames back to an ordinary monad in the next release with a lot of new enhancements to functionality, too, such as the ability to close and reinitialize resources. To reach me use my gmail.com address with username Gabriel439.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload