on master help sign in
Fix make_mask
3e7a8f9Sylvain HENRY
Data/Binary/Bits/Internal.hs+3−3
@@ -29,8 +29,8 @@ import GHC.Word
29#endif
29#endif
30
30
31-- | make_mask 3 = 00000111
31-- | make_mask 3 = 00000111
32−make_mask :: (FastBits a, Num a) => Int -> a
32+make_mask :: (Bits a, Num a) => Int -> a
33−make_mask n = (1 `fastShiftL` fromIntegral n) - 1
33+make_mask n = (1 `shiftL` fromIntegral n) - 1
34{-# SPECIALIZE make_mask :: Int -> Int #-}
34{-# SPECIALIZE make_mask :: Int -> Int #-}
35{-# SPECIALIZE make_mask :: Int -> Word #-}
35{-# SPECIALIZE make_mask :: Int -> Word #-}
36{-# SPECIALIZE make_mask :: Int -> Word8 #-}
36{-# SPECIALIZE make_mask :: Int -> Word8 #-}
@@ -39,7 +39,7 @@ make_mask n = (1 `fastShiftL` fromIntegral n) - 1
39{-# SPECIALIZE make_mask :: Int -> Word64 #-}
39{-# SPECIALIZE make_mask :: Int -> Word64 #-}
40
40
41-- | Keep only the n least-significant bits of the given value
41-- | Keep only the n least-significant bits of the given value
42−mask :: (FastBits a, Num a) => Int -> a -> a
42+mask :: (Bits a, Num a) => Int -> a -> a
43mask n v = v .&. make_mask n
43mask n v = v .&. make_mask n
44{-# INLINE mask #-}
44{-# INLINE mask #-}
45
45