Comparison of enumerator vs. iteratee package
Currently, there two popular choices which implement the iteratee pa开发者_运维技巧ttern:
- The enumerator package and
- the iteratee package.
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)?
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.
精彩评论