Hi,<div><br></div><div>for the first question you can look at combinators in <a href="http://hackage.haskell.org/packages/archive/iteratee/0.8.5.0/doc/html/Data-Iteratee-ListLike.html">Data.Iteratee.ListLike</a>  for iteratee package or <a href="http://hackage.haskell.org/packages/archive/enumerator/0.4.10/doc/html/Data-Enumerator-List.html">Data.Enumerator.List</a> for enumerator package. </div>
<div><br></div><div>I doubt that I understand the second question. It seems that Map is more natural here. You can transform list into enumerator for instance by <a href="http://hackage.haskell.org/packages/archive/enumerator/0.4.10/doc/html/Data-Enumerator.html#g:7">enumList</a>. But I wonder what is the reason for that in your case?</div>
<div><br></div><div><br></div><div><div><div class="gmail_quote">2011/6/28 Sævar Berg <span dir="ltr">&lt;<a href="mailto:s.b.saevarsson@gmail.com">s.b.saevarsson@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hey Café. <div><br></div><div>I&#39;ve been playing with Enumerators, Iteratees and Enumeratees today after having spent a few days writing a server application using lazy IO, then reading slides from Oleg&#39;s DEFUN8 talk notes, and I quote: &quot;Lazy IO in serious, server-side programming is unprofessional&quot;, &quot;I can talk a lot how disturbingly, distressingly wrong lazy IO is theoretically, how it breaks all equational reasoning&quot; after which my OCD self has been eating me up to take a proper look at this, so here I am.</div>

<div><br></div><div>I&#39;m already beginning to see how Iteratees, Enumerators and Enumeratees can be nifty, but I have a couple of questions about a couple of ideas and whether, and if so how they can be implemented.</div>

<div><br></div><div>The first question is, I think, to be solved with enumeratees but I can&#39;t really grok how. </div><div>Let&#39;s say I have an iteratee that consumes all input. Is it possible to implement an enumeratee or something else to stick between the enumerator and the iteratee to basically modify the input to the iteratee to only be a part of the input?</div>

<div><br></div><div>Something like this:</div><div><br></div><div>enumFile &quot;someFile&quot; &amp;&amp; printFileLines -- prints file with prepended line numbers</div><div>enumFile &quot;someFile&quot; ?? onlyGet10Lines &amp;&amp; printFileLines -- print only 10 lines</div>

<div><br></div><div>The second question could actually have an application in the server I&#39;m writing. I was wondering if it was possible to write iteratees/enumerators that would only generate/consume when a certain something was the next chunk to be processed? It&#39;s a bit hard to explain, but let me try to give you an example.</div>

<div><br></div><div>Let&#39;s say my application takes input from the network which contains commands that the server reacts to. Let&#39;s say I have a list of command handlers that I want to run this command through, but the handlers will only execute when they are passed the command that they are responsible for handling.</div>

<div>Can this list of command handlers be enumerators/iteratees/enumeratees? E.g. is it possible to &#39;concat&#39; them, making them each peek at the next chunk to see if it&#39;s theirs to handle and put it back if it isn&#39;t?</div>

<div><br></div><div>I know this is possible to do differently and I have an idea for how I would do this, but I&#39;m wondering if this is possible. If I can get answers to either or both of the questions it would help me a bit on my way to completely realize the roles that enumerators vs. iteratees vs. enumeratees have, as the lines seem a bit blurred -- sometimes, anyway.</div>

<div><br></div><div>Thanks in advance. :)</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></div>