on master help sign in
Fix GHC warnings
commited53a4b8a09aae07cd3df025fe14fbb6c8a0b9b9 authorSylvain HENRY <hsyl20@gmail.com> dateThu 26 Feb 2015, 21:49 (12 years ago) parent08842ad
1 file changed+28−21
Data/Binary/Bits/Get.hs+28−21
Data/Binary/Bits/Get.hs+28−21
@@ -87,7 +87,7 @@ module Data.Binary.Bits.Get
8787
8888 ) where
8989
90−import Data.Binary.Get as B ( runGet, Get, getByteString, getLazyByteString, isEmpty )
90+import Data.Binary.Get as B ( Get, getLazyByteString, isEmpty )
9191import Data.Binary.Get.Internal as B ( get, put, ensureN )
9292
9393import Data.ByteString as B
@@ -222,11 +222,13 @@ readWord8 n (S bs o)
222222
223223 -- the bits are in two different bytes
224224 -- make a word16 using both bytes, and then shift and mask
225− | n <= 8 = let w = (fromIntegral (unsafeHead bs) `shiftl_w16` 8) .|.
226− (fromIntegral (unsafeIndex bs 1))
227− m = make_mask n
228− w' = (w `shiftr_w16` (16 - o - n)) .&. m
229− in fromIntegral w'
225+ -- n <= 8
226+ | otherwise = let
227+ w = (fromIntegral (unsafeHead bs) `shiftl_w16` 8) .|.
228+ (fromIntegral (unsafeIndex bs 1))
229+ m = make_mask n
230+ w' = (w `shiftr_w16` (16 - o - n)) .&. m
231+ in fromIntegral w'
230232
231233{-# INLINE readWord16be #-}
232234readWord16be :: Int -> S -> Word16
@@ -301,22 +303,23 @@ readWithoutOffset (S bs o) shifterL shifterR n
301303 | bit_offset n == 0 && byte_offset n <= 4 =
302304 let segs = byte_offset n
303305 bn 0 = fromIntegral (unsafeHead bs)
304− bn n = (bn (n-1) `shifterL` 8) .|. fromIntegral (unsafeIndex bs n)
306+ bn m = (bn (m-1) `shifterL` 8) .|. fromIntegral (unsafeIndex bs m)
305307
306308 in bn (segs-1)
307309
308− | n <= 64 = let segs = byte_offset n
309− o' = bit_offset (n - 8 + o)
310+ -- n <= 64
311+ | otherwise = let segs = byte_offset n
312+ o' = bit_offset (n - 8 + o)
310313
311− bn 0 = fromIntegral (unsafeHead bs)
312− bn n = (bn (n-1) `shifterL` 8) .|. fromIntegral (unsafeIndex bs n)
314+ bn 0 = fromIntegral (unsafeHead bs)
315+ bn m = (bn (m-1) `shifterL` 8) .|. fromIntegral (unsafeIndex bs m)
313316
314− msegs = bn (segs-1) `shifterL` o'
317+ msegs = bn (segs-1) `shifterL` o'
315318
316− last = (fromIntegral (unsafeIndex bs segs)) `shifterR` (8 - o')
319+ lst = (fromIntegral (unsafeIndex bs segs)) `shifterR` (8 - o')
317320
318− w = msegs .|. last
319− in w
321+ w = msegs .|. lst
322+ in w
320323
321324readWithOffset :: (Bits a, Num a)
322325 => S -> (a -> Int -> a) -> (a -> Int -> a) -> Int -> a
@@ -328,17 +331,18 @@ readWithOffset (S bs o) shifterL shifterR n
328331 segs = byte_offset n'
329332
330333 bn 0 = 0
331− bn n = (bn (n-1) `shifterL` 8) .|. fromIntegral (unsafeIndex bs n)
334+ bn m = (bn (m-1) `shifterL` 8) .|. fromIntegral (unsafeIndex bs m)
332335
333336 o' = bit_offset n'
334337
335338 mseg = bn segs `shifterL` o'
336339
337− last | o' > 0 = (fromIntegral (unsafeIndex bs (segs + 1))) `shifterR` (8 - o')
338− | otherwise = 0
340+ lst | o' > 0 = (fromIntegral (unsafeIndex bs (segs + 1))) `shifterR` (8 - o')
341+ | otherwise = 0
339342
340− w = top .|. mseg .|. last
343+ w = top .|. mseg .|. lst
341344 in w
345+ | otherwise = error $ "Invalid offset (" ++ show n ++ " > 64)"
342346
343347------------------------------------------------------------------------
344348-- | 'BitGet' is a monad, applicative and a functor. See 'runBitGet'
@@ -485,8 +489,12 @@ shiftl_w16 :: Word16 -> Int -> Word16
485489shiftl_w32 :: Word32 -> Int -> Word32
486490shiftl_w64 :: Word64 -> Int -> Word64
487491
492+shiftr_w8 :: Word8 -> Int -> Word8
493+shiftr_w16 :: Word16 -> Int -> Word16
494+shiftr_w32 :: Word32 -> Int -> Word32
495+shiftr_w64 :: Word64 -> Int -> Word64
496+
488497#if defined(__GLASGOW_HASKELL__) && !defined(__HADDOCK__)
489−shiftl_w8 (W8# w) (I# i) = W8# (w `uncheckedShiftL#` i)
490498shiftl_w16 (W16# w) (I# i) = W16# (w `uncheckedShiftL#` i)
491499shiftl_w32 (W32# w) (I# i) = W32# (w `uncheckedShiftL#` i)
492500
@@ -513,7 +521,6 @@ shiftr_w64 (W64# w) (I# i) = W64# (w `uncheckedShiftRL#` i)
513521#endif
514522
515523#else
516−shiftl_w8 = shiftL
517524shiftl_w16 = shiftL
518525shiftl_w32 = shiftL
519526shiftl_w64 = shiftL