module Data.Binary.Bits
( BinaryBit(getBits, putBits)
) where
import qualified Data.Binary.Bits.Get as Get
import qualified Data.Binary.Bits.Put as Put
import qualified Data.Word as Word
class BinaryBit a where
putBits :: Int -> a -> Put.BitPut ()
getBits :: Int -> Get.BitGet a
instance BinaryBit Bool where
putBits :: Int -> Bool -> BitPut ()
putBits = forall a b. a -> b -> a
const Bool -> BitPut ()
Put.putBool
getBits :: Int -> BitGet Bool
getBits = forall a b. a -> b -> a
const BitGet Bool
Get.getBool
instance BinaryBit Word.Word8 where
putBits :: Int -> Word8 -> BitPut ()
putBits = Int -> Word8 -> BitPut ()
Put.putWord8
getBits :: Int -> BitGet Word8
getBits = Int -> BitGet Word8
Get.getWord8
instance BinaryBit Word.Word16 where
putBits :: Int -> Word16 -> BitPut ()
putBits = Int -> Word16 -> BitPut ()
Put.putWord16be
getBits :: Int -> BitGet Word16
getBits = Int -> BitGet Word16
Get.getWord16be
instance BinaryBit Word.Word32 where
putBits :: Int -> Word32 -> BitPut ()
putBits = Int -> Word32 -> BitPut ()
Put.putWord32be
getBits :: Int -> BitGet Word32
getBits = Int -> BitGet Word32
Get.getWord32be
instance BinaryBit Word.Word64 where
putBits :: Int -> Word64 -> BitPut ()
putBits = Int -> Word64 -> BitPut ()
Put.putWord64be
getBits :: Int -> BitGet Word64
getBits = Int -> BitGet Word64
Get.getWord64be