iteratee ByteStringLike conversions

Michael Baikov manpacket at
Fri Nov 11 04:48:06 GMT 2011

Are you sure that operating on [Word8] where it represents compressed
stream makes sence? To get benefits from compression size of data
should be quite large and operating on large lists of binary data is a
very good way to destroy the performance. So the idea  should be
operating on ByteStrings until you need data extracted and extract
data into that format you really want. So making it into generic case
is stupid, and if user really wants to destroy it's performance - it
is easy to achieve using threadDelay or mapStream B.unpack

Also enumInflate in iteratee-compress *should* be implemented in terms
of Enumeratee instread of Enumerator, because it's idea is to
transform data stream from one type to another and not the iteratee

On Fri, Nov 11, 2011 at 12:29 PM, Conrad Parker <conrad at> wrote:
> Hi,
> I recently converted zoom-cache to use (I.Nullable, LL.ListLike s
> Word8) constraints for byte streams. I then added support for
> compressed data blocks, using enumInflate from iteratee-compress:
> enumInflate :: MonadIO m => Format -> DecompressParams -> Enumerator
> ByteString m a
> In order to use that unmodified, I wanted a function of type (Iteratee
> ByteString m a -> Iteratee s m a), and ended up writing a simple
> typeclass for ByteStringLike streams:
> class (I.Nullable s, LL.ListLike s Word8) => ByteStringLike s where
>    likeFromByteString :: ByteString -> s
>    likeToByteString   :: s -> ByteString
> instance ByteStringLike [Word8] where
>    likeFromByteString = B.unpack
>    likeToByteString   = B.pack
> instance ByteStringLike ByteString where
>    likeFromByteString = id
>    likeToByteString   = id
> allowing the desired conversion function:
> iterToByteStringLike :: (I.Nullable s, LL.ListLike s Word8,
> ByteStringLike s, Monad m)
>                     => Iteratee ByteString m a -> Iteratee s m a
> iterToByteStringLike = I.joinI . I.mapChunks likeToByteString
> This all seems a bit circuitous.
> 1) Does a similar typeclass already exist?
> 2) Is there a simpler way to use enumInflate from an arbitrary byte stream?
> 3) It would be nice to just generalize the type of enumInflate, but it
> binds to the zlib C library and expects byte buffers, hence the direct
> ByteString interface; it would have to do something similar
> internally. Would these to/from iteratee conversion functions be
> generally useful for the Iteratee library?
> Code for Data.Iteratee.ByteStringLike is here:
> cheers,
> Conrad.
> _______________________________________________
> Iteratee mailing list
> Iteratee at

More information about the Iteratee mailing list