summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Klebinger <klebinger.andreas@gmx.at>2020-03-24 18:14:09 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-03-29 17:32:04 -0400
commit6c8f80d8876965539571d37d3c7f0fee43c300d2 (patch)
tree741cdf1aab82a0e9f0bacb86051d2ae359321fdd
parent7e7cb714173652165b8372c3450f4ccd6a377497 (diff)
downloadhaskell-6c8f80d8876965539571d37d3c7f0fee43c300d2.tar.gz
Correct haddocks for testBit in Data.Bits
It conflated the nth bit with the bit at offset n. Now we instead give the definition in terms of `bit and `.&.` on top of clearer phrasing.
-rw-r--r--libraries/base/Data/Bits.hs12
1 files changed, 8 insertions, 4 deletions
diff --git a/libraries/base/Data/Bits.hs b/libraries/base/Data/Bits.hs
index fd26d4e297..6379f208a8 100644
--- a/libraries/base/Data/Bits.hs
+++ b/libraries/base/Data/Bits.hs
@@ -168,10 +168,14 @@ class Eq a => Bits a where
-- | @x \`complementBit\` i@ is the same as @x \`xor\` bit i@
complementBit :: a -> Int -> a
- -- | Return 'True' if the @n@th bit of the argument is 1
- --
- -- Can be implemented using `testBitDefault' if @a@ is also an
- -- instance of 'Num'.
+ {-| @x \`testBit\` i@ is the same as @x .&. bit n == 1@
+
+ In other words it returns True if the bit at offset @n
+ is set.
+
+ Can be implemented using `testBitDefault' if @a@ is also an
+ instance of 'Num'.
+ -}
testBit :: a -> Int -> Bool
{-| Return the number of bits in the type of the argument. The actual