iteratee "folding" version of ilift
jwlato at gmail.com
Tue Nov 8 20:27:26 GMT 2011
Sure, looks useful enough. I don't like the name either, nor do I
like 'ilift'. I'll try to come up with something better for these two
in the next 24 hours. It's rather similar to 'mapAccumL', maybe
something along those lines would be appropriate.
On Tue, Nov 8, 2011 at 3:12 PM, Alex Lang <lang at tsurucapital.com> wrote:
> I propose a version of ilift which threads through an accumulator to
> consecutive invocations of the argument function.
> ifold :: (Monad m, Monad n) => (forall r. m r -> acc -> n (r, acc))
> -> acc -> Iteratee s m a -> Iteratee s n (a, acc)
> ifold f acc i = Iteratee $ \ od oc -> do
> (r, acc') <- flip f acc $
> runIter i (curry $ return . Left) (curry $ return . Right)
> either (uncurry (od . flip (,) acc'))
> (uncurry (oc . (ifold f acc' .))) r
> I don't think ifold is a very good name, but I could not think of a
> better one. I think it is a "fold" in the same sense that mapIteratee
> is a "map". Thinking about it, I don't think ilift is a very good name
> either, but I have no better suggestion.
> Iteratee mailing list
> Iteratee at projects.haskell.org
More information about the Iteratee