[Haskell-cafe] intercalate and (byte)strings

wman 666wman at gmail.com
Mon Dec 22 23:21:56 EST 2008


I encountered the following code :

-- B == Data.ByteString ; L == Data.ByteString.Lazy
contents' = B.intercalate B.empty $ L.toChunks contents

with a previously unencountered function intercalate. A quick google query
later i knew that it's just intersperse & concat nicely bundled and started
wondering why anybody would do this, as simple

contents' = B.concat $ L.toChunks contents

would do (probably nearly) the same. The only thing I am able to come up
with is that it somehow helps streamline the memory usage (if it has some
meaning).

Is there some reason to use intercalate <empty> <list> instead of concat
<list> (probably when dealing with non-lazy bytestrings) ?

Thx, wman.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20081223/35b79306/attachment.htm


More information about the Haskell-Cafe mailing list