[commit: packages/base] master: Derive `FiniteBits` for integral newtype wrappers (24268dd)

git at git.haskell.org git at git.haskell.org
Thu Jan 30 09:42:24 UTC 2014


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/24268dd7c01c71d38ff5b2956a3ee33672710d72/base

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

commit 24268dd7c01c71d38ff5b2956a3ee33672710d72
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date:   Thu Jan 30 10:34:25 2014 +0100

    Derive `FiniteBits` for integral newtype wrappers
    
    When `FiniteBits` was introduced in cddc9024e67a6d4c01bb190839d0134af8c907e0
    only the standard Haskell 2010 finite-size integral types were given a
    `FiniteBits` instance, however, since also a DEPRECATION warning was put
    in place (as per 701d9ed4b2bec5922709a91bfb625881d7dd47f0) for `bitSize`
    which might point people to to `FiniteBits`, it seems sensible to derive
    `FiniteBits` for all integral newtype wrappers as well.
    
    N.B.: This makes `Integer` the only type in `base` with a `Bits`
          instance but no `FiniteBits` instance.
    
    Signed-off-by: Herbert Valerio Riedel <hvr at gnu.org>


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

24268dd7c01c71d38ff5b2956a3ee33672710d72
 Foreign/C/Types.hs   |    2 +-
 GHC/Event/EPoll.hsc  |    4 ++--
 GHC/Event/KQueue.hsc |    6 +++---
 GHC/Event/Poll.hsc   |    4 ++--
 include/CTypes.h     |    2 +-
 5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/Foreign/C/Types.hs b/Foreign/C/Types.hs
index 3a35510..4aeae53 100644
--- a/Foreign/C/Types.hs
+++ b/Foreign/C/Types.hs
@@ -74,7 +74,7 @@ module Foreign.C.Types
         ) where
 
 import Foreign.Storable
-import Data.Bits        ( Bits(..) )
+import Data.Bits        ( Bits(..), FiniteBits(..) )
 import Data.Int         ( Int8,  Int16,  Int32,  Int64  )
 import Data.Word        ( Word8, Word16, Word32, Word64 )
 import Data.Typeable
diff --git a/GHC/Event/EPoll.hsc b/GHC/Event/EPoll.hsc
index fc81441..b808b21 100644
--- a/GHC/Event/EPoll.hsc
+++ b/GHC/Event/EPoll.hsc
@@ -39,7 +39,7 @@ available = False
 #include <sys/epoll.h>
 
 import Control.Monad (when)
-import Data.Bits (Bits, (.|.), (.&.))
+import Data.Bits (Bits, FiniteBits, (.|.), (.&.))
 import Data.Maybe (Maybe(..))
 import Data.Monoid (Monoid(..))
 import Data.Word (Word32)
@@ -163,7 +163,7 @@ newtype ControlOp = ControlOp CInt
 
 newtype EventType = EventType {
       unEventType :: Word32
-    } deriving (Show, Eq, Num, Bits)
+    } deriving (Show, Eq, Num, Bits, FiniteBits)
 
 #{enum EventType, EventType
  , epollIn  = EPOLLIN
diff --git a/GHC/Event/KQueue.hsc b/GHC/Event/KQueue.hsc
index b2132f6..bc88855 100644
--- a/GHC/Event/KQueue.hsc
+++ b/GHC/Event/KQueue.hsc
@@ -27,7 +27,7 @@ available = False
 #else
 
 import Control.Monad (when)
-import Data.Bits (Bits(..))
+import Data.Bits (Bits(..), FiniteBits(..))
 import Data.Maybe (Maybe(..))
 import Data.Monoid (Monoid(..))
 import Data.Word (Word16, Word32)
@@ -180,7 +180,7 @@ newtype Flag = Flag Word32
 #else
 newtype Flag = Flag Word16
 #endif
-    deriving (Bits, Eq, Num, Show, Storable)
+    deriving (Bits, FiniteBits, Eq, Num, Show, Storable)
 
 #{enum Flag, Flag
  , flagAdd     = EV_ADD
@@ -193,7 +193,7 @@ newtype Filter = Filter Word32
 #else
 newtype Filter = Filter Word16
 #endif
-    deriving (Bits, Eq, Num, Show, Storable)
+    deriving (Bits, FiniteBits, Eq, Num, Show, Storable)
 
 filterRead :: Filter
 filterRead = Filter (#const EVFILT_READ)
diff --git a/GHC/Event/Poll.hsc b/GHC/Event/Poll.hsc
index a832789..bb0b6e5 100644
--- a/GHC/Event/Poll.hsc
+++ b/GHC/Event/Poll.hsc
@@ -26,7 +26,7 @@ available = False
 
 import Control.Concurrent.MVar (MVar, newMVar, swapMVar)
 import Control.Monad ((=<<), liftM, liftM2, unless)
-import Data.Bits (Bits, (.|.), (.&.))
+import Data.Bits (Bits, FiniteBits, (.|.), (.&.))
 import Data.Maybe (Maybe(..))
 import Data.Monoid (Monoid(..))
 import Data.Word
@@ -150,7 +150,7 @@ data PollFd = PollFd {
     } deriving (Show)
 
 newtype Event = Event CShort
-    deriving (Eq, Show, Num, Storable, Bits)
+    deriving (Eq, Show, Num, Storable, Bits, FiniteBits)
 
 -- We have to duplicate the whole enum like this in order for the
 -- hsc2hs cross-compilation mode to work
diff --git a/include/CTypes.h b/include/CTypes.h
index 77b738c..ec18131 100644
--- a/include/CTypes.h
+++ b/include/CTypes.h
@@ -17,7 +17,7 @@
 --  // GHC can derive any class for a newtype, so we make use of that here...
 
 #define ARITHMETIC_CLASSES  Eq,Ord,Num,Enum,Storable,Real,Typeable
-#define INTEGRAL_CLASSES Bounded,Integral,Bits
+#define INTEGRAL_CLASSES Bounded,Integral,Bits,FiniteBits
 #define FLOATING_CLASSES Fractional,Floating,RealFrac,RealFloat
 
 #define ARITHMETIC_TYPE(T,B) \



More information about the ghc-commits mailing list