<div dir="ltr">It doesn&#39;t seem like you&#39;re trying to perform multiple actions simultaneously. For example, you don&#39;t need to be able to read from the server and send data back at the same time. Instead, you&#39;ll have a single thread of execution. Am I right?<div>

<br></div><div>If so, it seems like the simplest thing would be for you to allow users to write something like:</div><div><br></div><div style>    Conduit MsgFromServer m MsgToServer</div><div style><br></div><div style>
Assuming you had conduits to convert an incoming byte stream to a stream of MsgFromServer and the equivalent for sending, you&#39;d end up with something like:</div>
<div style><br></div><div style>    appSource appData $$ toMsgFromServer =$ clientSuppliedConduit =$ fromMsgToServer =$ appSink appData</div><div style><br></div><div style>Michael</div></div><div class="gmail_extra"><br>

<br><div class="gmail_quote">On Tue, Apr 9, 2013 at 1:09 PM, Alexander V Vershilov <span dir="ltr">&lt;<a href="mailto:alexander.vershilov@gmail.com" target="_blank">alexander.vershilov@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br clear="all">Hello.<br><br>I have next problem: I have a network client that connects to server, listens for messages and generate responces. So the control flow can be represended as:<br>

<br>server -- input -&gt; {generate output} -&gt; output<br>
<br>Output can be generated using default implementation or can overriden by user. <br><br>The main difficulty appeares when I need to add a user program on the top of this logic,<br>i.e. from user-side I want to have dsl:smth like<br>


<br>withClient $ do<br>   x &lt;- send message<br>   waitFor x<br>   timeout 5000000<br>   forever $ sendRandomMessage<br><br>i.e. an ability to send messages, waiting for some event (message to come), waiting for<br>timeout.<br>


<br>The question is how to define such logic without a big overhead. I see a solution using conduit, it&#39;s possible to create 3 processes: listener, user, sender.<br><br>                         +----&gt; user ----+<br>


                         |                    |<br>-input -&gt; listener +-----------------&gt;+---- sender -&gt;<br><br>and use TQueue or TChan to send messages between them, however there can be another possible solutions, that uses less resources, or another design. <br>

<span class="HOEnZb"><font color="#888888">
<br><br>-- <br>Alexander<br>
</font></span></div>
<br>_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
<br></blockquote></div><br></div>