[Haskell-cafe] compare iteratee with python's yield

Casey McCann cam at uptoisomorphism.net
Sat Jul 2 04:47:56 CEST 2011

On Fri, Jul 1, 2011 at 6:01 AM, Ertugrul Soeylemez <es at ertes.de> wrote:
> I don't know Python very well, but I suspect that its generators are
> really a sort of coroutines.  Iteratees are also coroutines, but their
> architecture is quite different.

Python generators were originally a sort of heavily restricted
coroutine mostly used to implement corecursive sequences, i.e. what we
use lazy lists for Haskell. As Python allows arbitrary side-effects,
this makes them pretty directly equivalent to using lazy I/O in
Haskell. They were later extended to be more like full coroutines,
allowing them to both generate and consume data. I imagine that
something akin to iteratees could be built on top of the
coroutine-style extended generators, but it would likely be more
reliant on the programmer not using things incorrectly and the benefit
of the whole idea is unclear in this context (for the reasons outlined
in the rest of your message).

- C.

More information about the Haskell-Cafe mailing list