<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">From: Felipe Almeida Lessa &lt;<a href="mailto:felipe.lessa@gmail.com">felipe.lessa@gmail.com</a>&gt;<br>

<br>
On Thu, Apr 28, 2011 at 1:10 PM, Felipe Almeida Lessa<br>
&lt;<a href="mailto:felipe.lessa@gmail.com">felipe.lessa@gmail.com</a>&gt; wrote:<br>
&gt; On Thu, Apr 28, 2011 at 12:09 PM, Felipe Almeida Lessa<br>
&gt; &lt;<a href="mailto:felipe.lessa@gmail.com">felipe.lessa@gmail.com</a>&gt; wrote:<br>
&gt;&gt; I foresee one problem: what is the leftover of &#39;manyToOne xs&#39; if each<br>
&gt;&gt; x in xs needs different lengths of input?<br>
&gt;&gt;<br>
&gt;&gt; One possible untested-but-compiling solution:<br>
&gt; [snip]<br>
&gt;<br>
&gt; Like I said, that manyToOne implementation isn&#39;t very predictable<br>
&gt; about leftovers. ?But I guess that if all your iteratees consume the<br>
&gt; same input OR if you don&#39;t care about leftovers, then it should be<br>
&gt; okay.<br>
<br>
Sorry for replying to myself again. =)<br>
<br>
I think you can actually give predictable semantics to manyToOne:<br>
namely, the leftovers from the last iteratee are returned.  This new<br>
implementation should be better:<br></blockquote><div><br></div><div>If you do this, the user needs to take care to order the iteratees so that the last iteratee has small leftovers.  Consider:</div><div><br></div><div>manyToOne [consumeALot, return ()]</div>
<div><br></div><div>In this case, the entire stream consumed by the first iteratee will need to be retained and passed on by manyToOne.  In many cases, the user may not know how much each iteratee will consume, which can make these semantics problematic.</div>
<div><br></div><div>Iteratee has &#39;enumPair&#39;, (renamed &#39;zip&#39; in HEAD) which returns the leftovers from whichever iteratee consumes more.  This avoids the problem of retaining extra data, and seems simpler to reason about.  Although if you really need to consume a predictable amount of data, the safest is probably to run the whole thing in a &#39;take&#39;.</div>
<div><br></div><div>John Lato</div></div>