[Haskell-cafe] Attoparsec concatenating combinator

Bryan O'Sullivan bos at serpentine.com
Mon Jun 6 19:18:37 CEST 2011


On Sun, Jun 5, 2011 at 11:00 AM, Yitzchak Gale <gale at sefer.org> wrote:

> If behind the scenes the concat is copying directly from slices of the
> original
> input, then no, in principle we're not saving much then.
> I thought there were *two* copies going on.
>

If you're using the specialised functions like attoparsec's takeWhile, then
all they do is return a view into the underlying array. No copying occurs
until the concat itself. Now that I think of it: in principle, you could
write a specialised concat that would check the pointer/offset/length
combinations of its arguments and, if they all abutted perfectly, would just
return a new view into that same array, sans copying. (You'd have to hide it
behind unsafePerformIO, of course.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110606/94a7ae36/attachment.htm>


More information about the Haskell-Cafe mailing list