Mike Izbicki
Mike Izbicki

Reputation: 6366

Is there a parametric version of lazy `ByteString`?

My understanding is that ByteStrings are just lists of vectors of Word8s. This packaging gives better memory and speed performance on binary streams. Similarly, the Text type boosts performance on Char streams.

But what if I have Int streams, or Double streams? Is there a parametric version of ByteString that is easy to use with different data types? I assume it would only make sense to use on unboxable types.

Upvotes: 7

Views: 211

Answers (2)

sclv
sclv

Reputation: 38893

Vector is the go-to choice for strict arrays. StorableVector attempts to be a more ByteString-like interface, including lazy, chunked behavior, and I believe was even written originally as a generalization of the ByteString code: http://hackage.haskell.org/package/storablevector

Upvotes: 12

Philip JF
Philip JF

Reputation: 28539

If you only want the "strict" versions use vector which is part of the platform. Vector has both unboxed and (fully generic) boxed variants. Vector also includes agressive high quality stream fusion.

Upvotes: 1

Related Questions