
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...]

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...]
Andrew, Maybe you could look at the generic encode/decode in this paper: people.cs.uu.nl/johanj/publications/ComparingGP.pdf 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. -- Sebastiaan.

Andrew Coppin
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.
The original Binary library, circa 1998, was based on bit-streams rather than bytes. You might be able to dig up a copy and bring it back to life. http://citeseer.ist.psu.edu/wallace98bits.html ftp://ftp.cs.york.ac.uk/pub/malcolm/ismm98.html Regards, Malcolm

Hello Malcolm, Wednesday, June 18, 2008, 4:36:40 PM, you wrote:
The original Binary library, circa 1998, was based on bit-streams rather than bytes. You might be able to dig up a copy and bring it back to life.
http://citeseer.ist.psu.edu/wallace98bits.html ftp://ftp.cs.york.ac.uk/pub/malcolm/ismm98.html
well, i've seen ghc-compatible Binary library flying around which supported bit fields. it was in pre-hackage days, but it should be pretty easy to find this module -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

Malcolm Wallace wrote:
The original Binary library, circa 1998, was based on bit-streams rather than bytes. You might be able to dig up a copy and bring it back to life.
This derivative (by Hal Daume III) works with GHC 6.8.2 (I haven't tried 6.8.3): http://hackage.haskell.org/cgi-bin/hackage-scripts/package/NewBinary Not sure how to compares to the original version. It does appear to still support bit-oriented I/O though. j. (Note: I just fixed the cabal stuff to work with 6.8.2 minutes ago, so if have tried it before, it should work now).

Hello Andrew, Wednesday, June 18, 2008, 12:05:31 AM, you wrote:
what Binary does, but with single-bit precision? [I presume Binary is
http://haskell.org/haskellwiki/Library/AltBinary it's not maintained, so consider it as "last hope" :) -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

On Tue, Jun 17, 2008 at 1:05 PM, Andrew Coppin
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?
The binary-strict library includes this functionality. It also has several other useful pieces of functionality. It's rather a shame the binary and binary-strict developers haven't merged their efforts :-(
participants (6)
-
Andrew Coppin
-
Bryan O'Sullivan
-
Bulat Ziganshin
-
Jeremy Shaw
-
Malcolm Wallace
-
Sebastiaan Visser