Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 283
Mike Izbicki Avatar asked May 30 '13 04:05

Mike Izbicki


2 Answers

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

like image 193
sclv Avatar answered Sep 22 '22 22:09

sclv


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.

like image 20
Philip JF Avatar answered Sep 22 '22 22:09

Philip JF