iteratee [] suggestion for mapStreamM
John Lato
jwlato at gmail.com
Mon Aug 23 14:24:28 EDT 2010
Hi Ben,
Thanks very much for submitting this; it looks very good. I'm sure it will
be helpful. I could distribute this with the package if you like, but
perhaps you might want to put some of this on the wiki? I think it would
reach more viewers then.
Sincerely,
John
On Mon, Aug 23, 2010 at 6:36 PM, Ben <midfield at gmail.com> wrote:
> i have been unable to finish my iteratee tutorial due to my job being
> crazy right now. i might be able to get back to it at a later date,
> but with the advent of the new simplified iteratee library, i thought
> it might be useful to have in this unfinished form, because the most
> finished part is about CPS-style versus ADT style. it might be useful
> to cut out (it's at the end, under the CPS heading) to help teach
> people how to convert their old-style iteratee code into CPS style.
>
> best, b
>
> On Mon, Aug 16, 2010 at 8:10 AM, John Lato <jwlato at gmail.com> wrote:
> > On Sun, Aug 15, 2010 at 1:20 AM, Ben <midfield at gmail.com> wrote:
> >>
> >> A suggestion for Data.Iteratee.ListLike :
> >>
> >> mapStreamM :: (Monad m) =>
> >> (el -> m el')
> >> -> Enumeratee [el] [el'] m a
> >> mapStreamM mf = eneeCheckIfDone (liftI . step)
> >> where
> >> step k (Chunk xs)
> >> | LL.null xs = liftI (step k)
> >> | otherwise = joinIM $ do ys <- mapM mf xs
> >> return $ mapStreamM mf $ k (Chunk ys)
> >> step k s = idone (liftI k) s
> >>
> >> an improvement would be something that actually uses the ListLike
> >> class (or some monadic extension of it.)
> >
> > Thanks for this suggestion; I think it would be useful.
> > This gets to a related issue I've been struggling with for some time. I
> > would like for iteratee to support using mutable buffers. I believe this
> > could be very efficient as it would completely bypass a large amount of
> > allocation/gc work. There are two primary issues I have so far:
> > 1) I don't know how to make them 100% compatible with standard iteratees
> > because the Monad instance needs to be slightly different. In my test
> > implementation I use a newtype of Iteratee, which is mostly satisfactory.
> > 2) Everything in ListLike needs to be re-written for a monadic version.
> > ListLike itself is not widely used, but for mutable buffers there's even
> > more disparity. At least ListLike instances for Vector, Text, etc. can
> be
> > written relatively mechanically.
> > Is there any interest in further developments in this direction?
> > John
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.haskell.org/pipermail/iteratee/attachments/20100823/bf642a82/attachment-0001.htm
More information about the Iteratee
mailing list