@@ -358,18 +358,22 @@ intFromNat = fromIntegral
358
358
data IntMap a = Bin {- # UNPACK #-} !Prefix
359
359
! (IntMap a )
360
360
! (IntMap a )
361
- -- Invariant: Nil is never found as a child of Bin.
362
361
| Tip {- # UNPACK #-} !Key a
363
362
| Nil
364
-
365
- -- | A @Prefix@ stores the most significant bits shared by all keys in a Bin,
366
- -- immediately followed a single set bit, which we refer to as "mask".
367
- --
368
- -- Invariant: All keys in the left child have the mask bit unset, and all keys
369
- -- in the right child have the mask bit set.
370
- --
371
- -- It follows from the invariant that the @Int@ value of the @Prefix@ is the
372
- -- smallest value that can be present in the right child.
363
+ -- IntMap invariants:
364
+ -- * Nil is never found as a child of Bin.
365
+ -- * The Prefix of a Bin is the common high-order bits that all keys in the
366
+ -- Bin share.
367
+ -- * We call the bit immediately following the shared prefix the mask bit.
368
+ -- All keys in the left child of a Bin have the mask bit unset, and all keys
369
+ -- in the right child have the mask bit set.
370
+
371
+ -- | A @Prefix@ is some prefix of high-order bits of an @Int@.
372
+ --
373
+ -- This is represented by an @Int@ which starts with the prefix bits,
374
+ -- immediately followed by a set bit. This is the mask bit for a @Bin@. It
375
+ -- follows from the IntMap invariants that this @Int@ value is the smallest
376
+ -- value that can be present in its right child.
373
377
newtype Prefix = Prefix { unPrefix :: Int }
374
378
deriving (Eq , Lift )
375
379
0 commit comments