iteratee [] suggestion for mapStreamM

Ben midfield at gmail.com
Mon Aug 23 13:36:06 EDT 2010


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 --------------
A non-text attachment was scrubbed...
Name: itertut.lhs
Type: application/octet-stream
Size: 14990 bytes
Desc: not available
Url : http://projects.haskell.org/pipermail/iteratee/attachments/20100823/2446e27b/attachment.obj 


More information about the Iteratee mailing list