Hi, for the first question you can look at combinators in Data.Iteratee.ListLike<http://hackage.haskell.org/packages/archive/iteratee/0.8.5.0/doc/html/Data-Iteratee-ListLike.html> for iteratee package or Data.Enumerator.List<http://hackage.haskell.org/packages/archive/enumerator/0.4.10/doc/html/Data-Enumerator-List.html> for enumerator package.
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 enumList<http://hackage.haskell.org/packages/archive/enumerator/0.4.10/doc/html/Data-Enumerator.html#g:7>. But I wonder what is the reason for that in your case? 2011/6/28 Sævar Berg <s.b.saevars...@gmail.com> > Hey Café. > > I'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's DEFUN8 talk notes, and I quote: "Lazy IO in > serious, server-side programming is unprofessional", "I can talk a lot how > disturbingly, distressingly wrong lazy IO is theoretically, how it breaks > all equational reasoning" after which my OCD self has been eating me up to > take a proper look at this, so here I am. > > I'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. > > The first question is, I think, to be solved with enumeratees but I can't > really grok how. > Let'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? > > Something like this: > > enumFile "someFile" && printFileLines -- prints file with prepended line > numbers > enumFile "someFile" ?? onlyGet10Lines && printFileLines -- print only 10 > lines > > The second question could actually have an application in the server I'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's a bit hard to explain, but let me try to give you an > example. > > Let's say my application takes input from the network which contains > commands that the server reacts to. Let'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. > Can this list of command handlers be enumerators/iteratees/enumeratees? > E.g. is it possible to 'concat' them, making them each peek at the next > chunk to see if it's theirs to handle and put it back if it isn't? > > I know this is possible to do differently and I have an idea for how I > would do this, but I'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. > > Thanks in advance. :) > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > >
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe