summaryrefslogtreecommitdiff
path: root/libraries/base/Data/Bits.hs
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/base/Data/Bits.hs')
-rw-r--r--libraries/base/Data/Bits.hs28
1 files changed, 14 insertions, 14 deletions
diff --git a/libraries/base/Data/Bits.hs b/libraries/base/Data/Bits.hs
index 69a0377f9b..84b1c031b1 100644
--- a/libraries/base/Data/Bits.hs
+++ b/libraries/base/Data/Bits.hs
@@ -156,7 +156,7 @@ class Eq a => Bits a where
-- implementation (which ought to be equivalent to 'zeroBits' for
-- types which possess a 0th bit).
--
- -- /Since: 4.7.0.0/
+ -- @since 4.7.0.0
zeroBits :: a
zeroBits = clearBit (bit 0) 0
@@ -187,7 +187,7 @@ class Eq a => Bits a where
value of the argument is ignored. Returns Nothing
for types that do not have a fixed bitsize, like 'Integer'.
- /Since: 4.7.0.0/
+ @since 4.7.0.0
-}
bitSizeMaybe :: a -> Maybe Int
@@ -224,7 +224,7 @@ class Eq a => Bits a where
Defaults to 'shiftL' unless defined explicitly by an instance.
- /Since: 4.5.0.0/ -}
+ @since 4.5.0.0 -}
unsafeShiftL :: a -> Int -> a
{-# INLINE unsafeShiftL #-}
x `unsafeShiftL` i = x `shiftL` i
@@ -253,7 +253,7 @@ class Eq a => Bits a where
Defaults to 'shiftR' unless defined explicitly by an instance.
- /Since: 4.5.0.0/ -}
+ @since 4.5.0.0 -}
unsafeShiftR :: a -> Int -> a
{-# INLINE unsafeShiftR #-}
x `unsafeShiftR` i = x `shiftR` i
@@ -284,12 +284,12 @@ class Eq a => Bits a where
Can be implemented using `popCountDefault' if @a@ is also an
instance of 'Num'.
- /Since: 4.5.0.0/ -}
+ @since 4.5.0.0 -}
popCount :: a -> Int
-- |The 'FiniteBits' class denotes types with a finite, fixed number of bits.
--
--- /Since: 4.7.0.0/
+-- @since 4.7.0.0
class Bits b => FiniteBits b where
-- | Return the number of bits in the type of the argument.
-- The actual value of the argument is ignored. Moreover, 'finiteBitSize'
@@ -300,7 +300,7 @@ class Bits b => FiniteBits b where
-- 'bitSizeMaybe' = 'Just' . 'finiteBitSize'
-- @
--
- -- /Since: 4.7.0.0/
+ -- @since 4.7.0.0
finiteBitSize :: b -> Int
-- | Count number of zero bits preceding the most significant set bit.
@@ -320,7 +320,7 @@ class Bits b => FiniteBits b where
-- integral types are implemented using CPU specific machine
-- instructions.
--
- -- /Since: 4.8.0.0/
+ -- @since 4.8.0.0
countLeadingZeros :: b -> Int
countLeadingZeros x = (w-1) - go (w-1)
where
@@ -350,7 +350,7 @@ class Bits b => FiniteBits b where
-- integral types are implemented using CPU specific machine
-- instructions.
--
- -- /Since: 4.8.0.0/
+ -- @since 4.8.0.0
countTrailingZeros :: b -> Int
countTrailingZeros x = go 0
where
@@ -369,7 +369,7 @@ class Bits b => FiniteBits b where
--
-- Note that: @bitDefault i = 1 `shiftL` i@
--
--- /Since: 4.6.0.0/
+-- @since 4.6.0.0
bitDefault :: (Bits a, Num a) => Int -> a
bitDefault = \i -> 1 `shiftL` i
{-# INLINE bitDefault #-}
@@ -378,7 +378,7 @@ bitDefault = \i -> 1 `shiftL` i
--
-- Note that: @testBitDefault x i = (x .&. bit i) /= 0@
--
--- /Since: 4.6.0.0/
+-- @since 4.6.0.0
testBitDefault :: (Bits a, Num a) => a -> Int -> Bool
testBitDefault = \x i -> (x .&. bit i) /= 0
{-# INLINE testBitDefault #-}
@@ -388,7 +388,7 @@ testBitDefault = \x i -> (x .&. bit i) /= 0
-- This implementation is intentionally naive. Instances are expected to provide
-- an optimized implementation for their size.
--
--- /Since: 4.6.0.0/
+-- @since 4.6.0.0
popCountDefault :: (Bits a, Num a) => a -> Int
popCountDefault = go 0
where
@@ -397,7 +397,7 @@ popCountDefault = go 0
{-# INLINABLE popCountDefault #-}
--- Interpret 'Bool' as 1-bit bit-field; /Since: 4.7.0.0/
+-- Interpret 'Bool' as 1-bit bit-field; @since 4.7.0.0
instance Bits Bool where
(.&.) = (&&)
@@ -557,7 +557,7 @@ instance Bits Integer where
-- 'fromIntegral', which is itself optimized with rules for @base@ types but may
-- go through 'Integer' for some type pairs.)
--
--- /Since: 4.8.0.0/
+-- @since 4.8.0.0
toIntegralSized :: (Integral a, Integral b, Bits a, Bits b) => a -> Maybe b
toIntegralSized x -- See Note [toIntegralSized optimization]