[Haskell-cafe] ANNOUNCE: enumerator, an alternative iteratee package

John Millikin jmillikin at gmail.com
Thu Aug 19 01:40:50 EDT 2010

I'm glad to hear you found it useful!

For implementing selectList, have you considered using the "consume"
iteratee? I suspect it would simplify your code to something like:

selectList a b c d = do
    res <- run $ select a b c d ==<< consume
    case res of
        Left e -> error e
        Right x -> return x

You might also want to look at the iteratee combinators (returnI,
yield, continue), which would reduce some boilerplate, eg:

"Iteratee $ return $ Continue k" becomes "continue k"
"Iteratee $ return $ Yield x EOF" becomes "yield x EOF"

On Wed, Aug 18, 2010 at 22:24, Michael Snoyman <michael at snoyman.com> wrote:
> John,
> This package looks very promising. I used iteratee for the yaml package, but
> I had many of the concerns that you have mentioned below. Version 0.2 of
> persistent is going to have some form of an enumerator interface for getting
> the results of a query, and I eventually decided that iteratee was
> introducing too much complexity to be a good candidate. However, I was able
> to port the package[1] over to enumerator in about half an hour; I
> especially benefited from your example applications.
> The only concern that I had was the possible inefficiency of representing
> all chunks as a list. In the case of persistent, the enumerator will
> *always* generate a one-lengthed list, and the most common operation is
> selectList, which returns all results as a list. If I used your consume
> function, I believe there would be a *lot* of list traversals. Instead,
> selectList[2] uses ([a] -> [a]) for building up the result internally. I
> haven't really thought the issue through fully, so I can recommend anything
> better. Perhaps more importantly, the simplification introduced by just
> dealing with lists is well received.
> Keep up the good work, I look forward to seeing more about enumerator.
> Michael
> [1] http://github.com/snoyberg/persistent/tree/enumerator
> [2] http://github.com/snoyberg/persistent/blob/enumerator/Database/Persist/Base.hs#L322

More information about the Haskell-Cafe mailing list