module HaskellWorks.Data.Bits.FixedBitSize
    ( FixedBitSize(..)
    ) where

import Data.Word
import HaskellWorks.Data.Positioning

-- | Class of values that have a fix bit size
class FixedBitSize a where
  -- | Get the bit size of a value of given type.
  --
  -- >>> fixedBitSize (undefined :: Word8)
  -- 8
  fixedBitSize :: a -> Count

instance FixedBitSize Bool where
  fixedBitSize :: Bool -> Count
fixedBitSize Bool
_ = Count
1

instance FixedBitSize Word8 where
  fixedBitSize :: Word8 -> Count
fixedBitSize Word8
_ = Count
8

instance FixedBitSize Word16 where
  fixedBitSize :: Word16 -> Count
fixedBitSize Word16
_ = Count
16

instance FixedBitSize Word32 where
  fixedBitSize :: Word32 -> Count
fixedBitSize Word32
_ = Count
32

instance FixedBitSize Word64 where
  fixedBitSize :: Count -> Count
fixedBitSize Count
_ = Count
64