[Haskell-cafe] Bit streams

Sebastiaan Visser sfvisser at cs.uu.nl
Wed Jun 18 06:45:54 EDT 2008

On Jun 17, 2008, at 10:05 PM, Andrew Coppin wrote:

> OK, so today I tried to write my first program using the Binary  
> library. And I've hit a snag: It appears the library will only  
> handle data that is byte-aligned. So if I try to write three Bool  
> values, it uses three bytes, not three bits.
> Before I sit down and spend 3 months designing my own library from  
> scratch, does anybody know of an existing library that allows you  
> to do what Binary does, but with single-bit precision? [I presume  
> Binary is byte-aligned for efficiency...]


Maybe you could look at the generic encode/decode in this paper:

When you look at some more literature about generic programming the  
(bit-aligned) encode and decode are quite common examples. It  
shouldn't be that hard to de-generify them, if you even want that.


More information about the Haskell-Cafe mailing list