> From: Tilo Wiklund <notevent...@gmail.com> > > I am probably missing something obvious or something relating to > optimisation/server software but defining iteratees as "Iteratee s a = > Cont (s -> Either (s, a) (Iteratee s a))" seems to lead to a more > natural monad instance, and does not suffer from (what seems to me to > be an issue) having to make predictions about the stream it will be > passed. > > My question is thus, why the "rest" stream has to be carried by an > Iteratee constructor, rather then be part of the value of the > continuation function.
Bas's reply is spot-on. To directly answer your question, there is no technical reason and both implementations are possible (among others). The reasons for the choice (at least in the iteratee library) have to do with the types that arise for enumerators and iteratee combinators for a given implementation. There is a good discussion of this in the comments in Oleg's source code. Currently I prefer the CPS-style. It looks more complicated, and it can't be written in Haskell-98, but otherwise it seems easier to use with comparable (or better) performance. Other factors (chunk size, chunk type) seem to have a much more significant effect on performance than this. There are performance differences between the two IterateeG/IterGV implementations, but as far as I know neither one is better overall. John _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe