Comparison of enumerator vs. iteratee package
Asked Answered
C

1

20

Currently, there two popular choices which implement the iteratee pattern:

What are their relative benefits? Is one better than the other, or does it depend on the use-case (and if so, what are the criteria to decide which one to use)?

Condon answered 6/10, 2011 at 13:2 Comment(0)
D
21

There are at least three iteratee libraries:

  • enumerator
  • iteratee
  • iterIO

I believe that the enumerator library is the preferred one currently, because of its simplicity. It's also the one I use for my projects, if you care. The other two packages are more flexible and can be faster at times, but they are also more complicated. If you want to learn iteratees I suggest starting with enumerator. It is the most direct implementation of Oleg's original idea.

If you have a particular use case and need a lot of features with the standard iteratee approach, you may want to consider using the iteratee package. In more complicated scenarios you may also want to try the iterIO package, which has a slightly different and more flexible concept. In particular iteratees can communicate with the enumerator, which is not possible in the other two packages.

If all three packages are not flexible enough, you probably want to write your coroutines yourself with the monad-coroutine package. Iteratees and enumerators are a special type of coroutines, which can be composed in a certain way. The monad-coroutine package gives you the general type and allows you to employ your own concept of interaction.

Danita answered 6/10, 2011 at 13:41 Comment(4)
One minor nit: iteratee iteratees can communicate with the enumerator as well. For example, that's how seek is implemented. It's not as sophisticated as the iterIO mechanism though.Outwear
@ertes, what about other properties, such as e.g. efficency/performance? Can libraries not using the same iteratee library be combined?Condon
Generally no, the libraries are not compatible to each other.Danita
Is iterIO actually "more complex"? I thought its entire goal was to be simpler by unifying the iteratee and enumerator concept.Axum

© 2022 - 2024 — McMap. All rights reserved.