[commit: ghc] master: Refactor Haddock comments in Data.Bits (828d724)

git at git.haskell.org git at git.haskell.org
Tue Nov 4 10:17:30 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/828d72489a8bad79e3675deed4b90807052ca0ee/ghc

>---------------------------------------------------------------

commit 828d72489a8bad79e3675deed4b90807052ca0ee
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date:   Tue Nov 4 11:06:53 2014 +0100

    Refactor Haddock comments in Data.Bits
    
    This removes the redundant "Minimal complete definition"-block included
    in the Haddock comment since Haddock renders the `MINIMAL`-pragma as
    well (which has is moved to the start of `class` definition for better
    readability of the source code)
    
    Morever, the references to `testBitDefault`, `bitDefault`, and
    `popCountDefault` have been moved to the respective methods' Haddock
    strings for which they can be used.


>---------------------------------------------------------------

828d72489a8bad79e3675deed4b90807052ca0ee
 libraries/base/Data/Bits.hs | 35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/libraries/base/Data/Bits.hs b/libraries/base/Data/Bits.hs
index cdef2fb..fead6fb 100644
--- a/libraries/base/Data/Bits.hs
+++ b/libraries/base/Data/Bits.hs
@@ -68,19 +68,16 @@ infixl 5 .|.
 
 {-# DEPRECATED bitSize "Use 'bitSizeMaybe' or 'finiteBitSize' instead" #-} -- deprecated in 7.8
 
-{-|
-The 'Bits' class defines bitwise operations over integral types.
-
-* Bits are numbered from 0 with bit 0 being the least
-  significant bit.
-
-Minimal complete definition: '.&.', '.|.', 'xor', 'complement',
-('shift' or ('shiftL' and 'shiftR')), ('rotate' or ('rotateL' and 'rotateR')),
-'bitSize', 'isSigned', 'testBit', 'bit', and 'popCount'.  The latter three can
-be implemented using `testBitDefault', 'bitDefault', and 'popCountDefault', if
- at a@ is also an instance of 'Num'.
--}
+-- | The 'Bits' class defines bitwise operations over integral types.
+--
+-- * Bits are numbered from 0 with bit 0 being the least
+--   significant bit.
 class Eq a => Bits a where
+    {-# MINIMAL (.&.), (.|.), xor, complement,
+                (shift | (shiftL, shiftR)),
+                (rotate | (rotateL, rotateR)),
+                bitSize, bitSizeMaybe, isSigned, testBit, bit, popCount #-}
+
     -- | Bitwise \"and\"
     (.&.) :: a -> a -> a
 
@@ -155,6 +152,9 @@ class Eq a => Bits a where
 
     -- | @bit /i/@ is a value with the @/i/@th bit set and all other bits clear.
     --
+    -- Can be implemented using `bitDefault' if @a@ is also an
+    -- instance of 'Num'.
+    --
     -- See also 'zeroBits'.
     bit               :: Int -> a
 
@@ -168,6 +168,9 @@ class Eq a => Bits a where
     complementBit     :: a -> Int -> a
 
     -- | Return 'True' if the @n at th bit of the argument is 1
+    --
+    -- 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
@@ -268,14 +271,12 @@ class Eq a => Bits a where
     {-| Return the number of set bits in the argument.  This number is
         known as the population count or the Hamming weight.
 
+        Can be implemented using `popCountDefault' if @a@ is also an
+        instance of 'Num'.
+
         /Since: 4.5.0.0/ -}
     popCount          :: a -> Int
 
-    {-# MINIMAL (.&.), (.|.), xor, complement,
-                (shift | (shiftL, shiftR)),
-                (rotate | (rotateL, rotateR)),
-                bitSize, bitSizeMaybe, isSigned, testBit, bit, popCount #-}
-
 -- |The 'FiniteBits' class denotes types with a finite, fixed number of bits.
 --
 -- /Since: 4.7.0.0/



More information about the ghc-commits mailing list