@@ -241,9 +241,6 @@ import Data.Functor.Identity (Identity(..))
241
241
242
242
infixl 9 \\ {- This comment teaches CPP correct behaviour -}
243
243
244
- -- A "Nat" is a natural machine word (an unsigned Int)
245
- type Nat = Word
246
-
247
244
{- -------------------------------------------------------------------
248
245
Operators
249
246
--------------------------------------------------------------------}
@@ -1678,18 +1675,18 @@ bitmapOf x = bitmapOfSuffix (suffixOf x)
1678
1675
The signatures of methods in question are placed after this comment.
1679
1676
----------------------------------------------------------------------}
1680
1677
1681
- lowestBitSet :: Nat -> Int
1682
- highestBitSet :: Nat -> Int
1683
- foldlBits :: Int -> (a -> Int -> a ) -> a -> Nat -> a
1684
- foldl'Bits :: Int -> (a -> Int -> a ) -> a -> Nat -> a
1685
- foldrBits :: Int -> (Int -> a -> a ) -> a -> Nat -> a
1686
- foldr'Bits :: Int -> (Int -> a -> a ) -> a -> Nat -> a
1678
+ lowestBitSet :: Word -> Int
1679
+ highestBitSet :: Word -> Int
1680
+ foldlBits :: Int -> (a -> Int -> a ) -> a -> Word -> a
1681
+ foldl'Bits :: Int -> (a -> Int -> a ) -> a -> Word -> a
1682
+ foldrBits :: Int -> (Int -> a -> a ) -> a -> Word -> a
1683
+ foldr'Bits :: Int -> (Int -> a -> a ) -> a -> Word -> a
1687
1684
#if MIN_VERSION_base(4,11,0)
1688
- foldMapBits :: Semigroup a => Int -> (Int -> a ) -> Nat -> a
1685
+ foldMapBits :: Semigroup a => Int -> (Int -> a ) -> Word -> a
1689
1686
#else
1690
- foldMapBits :: Monoid a => Int -> (Int -> a ) -> Nat -> a
1687
+ foldMapBits :: Monoid a => Int -> (Int -> a ) -> Word -> a
1691
1688
#endif
1692
- takeWhileAntitoneBits :: Int -> (Int -> Bool ) -> Nat -> Nat
1689
+ takeWhileAntitoneBits :: Int -> (Int -> Bool ) -> Word -> Word
1693
1690
1694
1691
{-# INLINE lowestBitSet #-}
1695
1692
{-# INLINE highestBitSet #-}
@@ -1702,24 +1699,24 @@ takeWhileAntitoneBits :: Int -> (Int -> Bool) -> Nat -> Nat
1702
1699
1703
1700
#if defined(__GLASGOW_HASKELL__)
1704
1701
1705
- lowestBitMask :: Nat -> Nat
1702
+ lowestBitMask :: Word -> Word
1706
1703
lowestBitMask x = x .&. negate x
1707
1704
{-# INLINE lowestBitMask #-}
1708
1705
1709
1706
lowestBitSet x = countTrailingZeros x
1710
1707
1711
1708
highestBitSet x = WORD_SIZE_IN_BITS - 1 - countLeadingZeros x
1712
1709
1713
- -- Reverse the order of bits in the Nat .
1714
- revNat :: Nat -> Nat
1710
+ -- Reverse the order of bits in the Word .
1711
+ revWord :: Word -> Word
1715
1712
#if WORD_SIZE_IN_BITS==32
1716
- revNat x1 = case ((x1 `shiftRL` 1 ) .&. 0x55555555 ) .|. ((x1 .&. 0x55555555 ) `shiftLL` 1 ) of
1713
+ revWord x1 = case ((x1 `shiftRL` 1 ) .&. 0x55555555 ) .|. ((x1 .&. 0x55555555 ) `shiftLL` 1 ) of
1717
1714
x2 -> case ((x2 `shiftRL` 2 ) .&. 0x33333333 ) .|. ((x2 .&. 0x33333333 ) `shiftLL` 2 ) of
1718
1715
x3 -> case ((x3 `shiftRL` 4 ) .&. 0x0F0F0F0F ) .|. ((x3 .&. 0x0F0F0F0F ) `shiftLL` 4 ) of
1719
1716
x4 -> case ((x4 `shiftRL` 8 ) .&. 0x00FF00FF ) .|. ((x4 .&. 0x00FF00FF ) `shiftLL` 8 ) of
1720
1717
x5 -> ( x5 `shiftRL` 16 ) .|. ( x5 `shiftLL` 16 );
1721
1718
#else
1722
- revNat x1 = case ((x1 `shiftRL` 1 ) .&. 0x5555555555555555 ) .|. ((x1 .&. 0x5555555555555555 ) `shiftLL` 1 ) of
1719
+ revWord x1 = case ((x1 `shiftRL` 1 ) .&. 0x5555555555555555 ) .|. ((x1 .&. 0x5555555555555555 ) `shiftLL` 1 ) of
1723
1720
x2 -> case ((x2 `shiftRL` 2 ) .&. 0x3333333333333333 ) .|. ((x2 .&. 0x3333333333333333 ) `shiftLL` 2 ) of
1724
1721
x3 -> case ((x3 `shiftRL` 4 ) .&. 0x0F0F0F0F0F0F0F0F ) .|. ((x3 .&. 0x0F0F0F0F0F0F0F0F ) `shiftLL` 4 ) of
1725
1722
x4 -> case ((x4 `shiftRL` 8 ) .&. 0x00FF00FF00FF00FF ) .|. ((x4 .&. 0x00FF00FF00FF00FF ) `shiftLL` 8 ) of
@@ -1740,14 +1737,14 @@ foldl'Bits prefix f z bitmap = go bitmap z
1740
1737
where ! bitmask = lowestBitMask bm
1741
1738
! bi = countTrailingZeros bitmask
1742
1739
1743
- foldrBits prefix f z bitmap = go (revNat bitmap) z
1740
+ foldrBits prefix f z bitmap = go (revWord bitmap) z
1744
1741
where go 0 acc = acc
1745
1742
go bm acc = go (bm `xor` bitmask) ((f $! (prefix+ (WORD_SIZE_IN_BITS - 1 )- bi)) acc)
1746
1743
where ! bitmask = lowestBitMask bm
1747
1744
! bi = countTrailingZeros bitmask
1748
1745
1749
1746
1750
- foldr'Bits prefix f z bitmap = go (revNat bitmap) z
1747
+ foldr'Bits prefix f z bitmap = go (revWord bitmap) z
1751
1748
where go 0 acc = acc
1752
1749
go bm ! acc = go (bm `xor` bitmask) ((f $! (prefix+ (WORD_SIZE_IN_BITS - 1 )- bi)) acc)
1753
1750
where ! bitmask = lowestBitMask bm
0 commit comments