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)?
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.
发布评论
评论(1)
至少有三个 iteratee 库:
我相信 enumerator 库是目前的首选库,因为它简单。如果你关心的话,这也是我在我的项目中使用的。其他两个包更灵活,有时可能更快,但它们也更复杂。如果您想学习迭代器,我建议从枚举器开始。这是奥列格最初想法的最直接的实现。
如果您有特定的用例并且需要标准 iteratee 方法的大量功能,您可能需要考虑使用 iteratee 包。在更复杂的场景中,您可能还想尝试 iterIO 包,它的概念略有不同且更灵活。特别是迭代器可以与枚举器通信,这在其他两个包中是不可能的。
如果这三个包都不够灵活,您可能需要使用 monad-coroutine 包自己编写协程。迭代器和枚举器是一种特殊类型的协程,可以按某种方式组合。 monad-coroutine 包为您提供了通用类型,并允许您使用自己的交互概念。
There are at least three iteratee libraries:
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.