diff options
Diffstat (limited to 'Data/BitSyntax.hs')
-rw-r--r-- | Data/BitSyntax.hs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Data/BitSyntax.hs b/Data/BitSyntax.hs index dbb43f45..6d14d0c1 100644 --- a/Data/BitSyntax.hs +++ b/Data/BitSyntax.hs | |||
@@ -131,15 +131,15 @@ data BitBlock = -- | Unsigned 8-bit int | |||
131 | 131 | ||
132 | -- Encodes a member of the Bits class as a series of bytes and returns the | 132 | -- Encodes a member of the Bits class as a series of bytes and returns the |
133 | -- ByteString of those bytes. | 133 | -- ByteString of those bytes. |
134 | getBytes :: (Integral a, Bounded a, Bits a) => a -> BS.ByteString | 134 | getBytes :: (Integral a, Bounded a, FiniteBits a) => a -> BS.ByteString |
135 | getBytes input = | 135 | getBytes input = |
136 | let getByte _ 0 = [] | 136 | let getByte _ 0 = [] |
137 | getByte x remaining = (fromIntegral $ (x .&. 0xff)) : | 137 | getByte x remaining = (fromIntegral $ (x .&. 0xff)) : |
138 | getByte (shiftR x 8) (remaining - 1) | 138 | getByte (shiftR x 8) (remaining - 1) |
139 | in | 139 | in |
140 | if (bitSize input `mod` 8) /= 0 | 140 | if (finiteBitSize input `mod` 8) /= 0 |
141 | then error "Input data bit size must be a multiple of 8" | 141 | then error "Input data bit size must be a multiple of 8" |
142 | else BS.pack $ getByte input (bitSize input `div` 8) | 142 | else BS.pack $ getByte input (finiteBitSize input `div` 8) |
143 | 143 | ||
144 | -- Performs the work behind PackBits | 144 | -- Performs the work behind PackBits |
145 | packBits :: (Word8, Int, [Word8]) -- ^ The current byte, the number of bits | 145 | packBits :: (Word8, Int, [Word8]) -- ^ The current byte, the number of bits |