getting a Binary module into the standard libs

Marcin 'Qrczak' Kowalczyk
Mon, 11 Nov 2002 21:44:22 +0000 (UTC)

Mon, 11 Nov 2002 10:12:57 -0800 (PST), Hal Daume III <hdaume@ISI.EDU> pisze:

>>   putBits :: BinHandle -> Int{-size-} -> Int{-value-} -> IO ()

> Any reason not to make those Word8s instead of Ints?

Any reason to limit value to 8?

I've heard: endianness, but if we fiddle with parts smaller than a byte
we already chose endianness when decided whether to fill bytes starting
from the low or high bit! Starting from low bit implies LE, starting
from high bit implies BE - anything else is inconsistent.

Whether the format is portable or not, allowing the size to be larger
than 8 doesn't change its portablility. So value could be Word8 or
Word32 etc.

For the bit count - they are generally expressed as Ints, as anything
which is guaranteed to be quite small. Word8 for bit count is quite
arbitrary and increases explicit conversions which need to be made -
Int is more common than Word8.

  __("<      Marcin Kowalczyk