[Haskell-cafe] stream/bytestring questions

Derek Elkins derek.a.elkins at gmail.com
Sun Feb 17 21:06:56 EST 2008

On Sun, 2008-02-17 at 18:02 -0800, Chad Scherrer wrote:
> On Feb 17, 2008 5:01 PM, Don Stewart <dons at galois.com> wrote:
> > yeah, with lists, as compared to bytestrings, there are:
> >
> >     * more complex operations to fuse
> >     * allocation is much cheaper (lazy list cons nodes)
> >     * built in desugaring for build/foldr fusion interferes (enumerations, comprehensions)
> >
> > so the benefits of fusing lists are less obvious than bytestrings, where
> > every fusion point knocks out a big array allocation, and they're a bit
> > more complex to get the full api going.
> Ok, that makes sense.
> > no, using the rules should be fine. you're not supposed to program in
> > the stream abstraction.
> I was working on some run-length encoding stuff and found it most
> natural to do a lot of it using unfoldr, and I had a state in the
> unfold that was naturally represented as a tuple. I got a little
> worried about all the packing and unpacking tuples not being optimized
> out, and this got me wondering about just using Streams directly. At
> the time, the Skip constructor for a Step felt natural to use in some
> places, which I thought could be really convenient. I dunno, maybe
> it's not an issue. Hmm, if it would help I can try to post some of the
> code...

It's -quite- possible that a coalgebraic perspective is much more
natural for your code/problem.  If that's the case, use it (the
coalgebraic perspective that is).  Obviously depending on the internals
of the stream library is not a good idea and using Streams directly was
not their intent, but it is your code.  Do what you will.

More information about the Haskell-Cafe mailing list