Skip to content

Commit 4c9bdf6

Browse files
committed
Remove the Nat synonym
1 parent 73c7dd0 commit 4c9bdf6

File tree

2 files changed

+16
-25
lines changed

2 files changed

+16
-25
lines changed

containers/src/Data/IntMap/Internal.hs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,6 @@ module Data.IntMap.Internal (
263263
, showTree
264264
, showTreeWith
265265

266-
-- * Internal types
267-
, Nat
268-
269266
-- * Utility
270267
, link
271268
, linkKey
@@ -333,9 +330,6 @@ import Text.Read
333330
import qualified Control.Category as Category
334331

335332

336-
-- A "Nat" is a natural machine word (an unsigned Int)
337-
type Nat = Word
338-
339333
{--------------------------------------------------------------------
340334
Types
341335
--------------------------------------------------------------------}

containers/src/Data/IntSet/Internal.hs

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,6 @@ import Data.Functor.Identity (Identity(..))
241241

242242
infixl 9 \\{-This comment teaches CPP correct behaviour -}
243243

244-
-- A "Nat" is a natural machine word (an unsigned Int)
245-
type Nat = Word
246-
247244
{--------------------------------------------------------------------
248245
Operators
249246
--------------------------------------------------------------------}
@@ -1678,18 +1675,18 @@ bitmapOf x = bitmapOfSuffix (suffixOf x)
16781675
The signatures of methods in question are placed after this comment.
16791676
----------------------------------------------------------------------}
16801677

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
16871684
#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
16891686
#else
1690-
foldMapBits :: Monoid a => Int -> (Int -> a) -> Nat -> a
1687+
foldMapBits :: Monoid a => Int -> (Int -> a) -> Word -> a
16911688
#endif
1692-
takeWhileAntitoneBits :: Int -> (Int -> Bool) -> Nat -> Nat
1689+
takeWhileAntitoneBits :: Int -> (Int -> Bool) -> Word -> Word
16931690

16941691
{-# INLINE lowestBitSet #-}
16951692
{-# INLINE highestBitSet #-}
@@ -1702,24 +1699,24 @@ takeWhileAntitoneBits :: Int -> (Int -> Bool) -> Nat -> Nat
17021699

17031700
#if defined(__GLASGOW_HASKELL__)
17041701

1705-
lowestBitMask :: Nat -> Nat
1702+
lowestBitMask :: Word -> Word
17061703
lowestBitMask x = x .&. negate x
17071704
{-# INLINE lowestBitMask #-}
17081705

17091706
lowestBitSet x = countTrailingZeros x
17101707

17111708
highestBitSet x = WORD_SIZE_IN_BITS - 1 - countLeadingZeros x
17121709

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
17151712
#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
17171714
x2 -> case ((x2 `shiftRL` 2) .&. 0x33333333) .|. ((x2 .&. 0x33333333) `shiftLL` 2) of
17181715
x3 -> case ((x3 `shiftRL` 4) .&. 0x0F0F0F0F) .|. ((x3 .&. 0x0F0F0F0F) `shiftLL` 4) of
17191716
x4 -> case ((x4 `shiftRL` 8) .&. 0x00FF00FF) .|. ((x4 .&. 0x00FF00FF) `shiftLL` 8) of
17201717
x5 -> ( x5 `shiftRL` 16 ) .|. ( x5 `shiftLL` 16);
17211718
#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
17231720
x2 -> case ((x2 `shiftRL` 2) .&. 0x3333333333333333) .|. ((x2 .&. 0x3333333333333333) `shiftLL` 2) of
17241721
x3 -> case ((x3 `shiftRL` 4) .&. 0x0F0F0F0F0F0F0F0F) .|. ((x3 .&. 0x0F0F0F0F0F0F0F0F) `shiftLL` 4) of
17251722
x4 -> case ((x4 `shiftRL` 8) .&. 0x00FF00FF00FF00FF) .|. ((x4 .&. 0x00FF00FF00FF00FF) `shiftLL` 8) of
@@ -1740,14 +1737,14 @@ foldl'Bits prefix f z bitmap = go bitmap z
17401737
where !bitmask = lowestBitMask bm
17411738
!bi = countTrailingZeros bitmask
17421739

1743-
foldrBits prefix f z bitmap = go (revNat bitmap) z
1740+
foldrBits prefix f z bitmap = go (revWord bitmap) z
17441741
where go 0 acc = acc
17451742
go bm acc = go (bm `xor` bitmask) ((f $! (prefix+(WORD_SIZE_IN_BITS-1)-bi)) acc)
17461743
where !bitmask = lowestBitMask bm
17471744
!bi = countTrailingZeros bitmask
17481745

17491746

1750-
foldr'Bits prefix f z bitmap = go (revNat bitmap) z
1747+
foldr'Bits prefix f z bitmap = go (revWord bitmap) z
17511748
where go 0 acc = acc
17521749
go bm !acc = go (bm `xor` bitmask) ((f $! (prefix+(WORD_SIZE_IN_BITS-1)-bi)) acc)
17531750
where !bitmask = lowestBitMask bm

0 commit comments

Comments
 (0)