[commit: packages/primitive] ghc-head: Fix build with GHC >= 7.7 (base 4.7) (e8a0cea)

git at git.haskell.org git at git.haskell.org
Thu Sep 26 11:45:06 CEST 2013


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

On branch  : ghc-head
Link       : http://git.haskell.org/packages/primitive.git/commitdiff/e8a0cea07d8a7e38b5dd0a7a0cde3963c1b58716

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

commit e8a0cea07d8a7e38b5dd0a7a0cde3963c1b58716
Author: Bryan O'Sullivan <bos at serpentine.com>
Date:   Tue Sep 24 11:02:38 2013 -0700

    Fix build with GHC >= 7.7 (base 4.7)


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

e8a0cea07d8a7e38b5dd0a7a0cde3963c1b58716
 Data/Primitive/Array.hs           |    5 ++---
 Data/Primitive/ByteArray.hs       |    5 ++---
 Data/Primitive/Internal/Compat.hs |   19 ++++++++++++++++++-
 Data/Primitive/MutVar.hs          |    3 ++-
 Data/Primitive/Types.hs           |   15 +++++++--------
 5 files changed, 31 insertions(+), 16 deletions(-)

diff --git a/Data/Primitive/Array.hs b/Data/Primitive/Array.hs
index 48cc82e..9e066d1 100644
--- a/Data/Primitive/Array.hs
+++ b/Data/Primitive/Array.hs
@@ -26,7 +26,7 @@ import GHC.Prim
 
 import Data.Typeable ( Typeable )
 import Data.Data ( Data(..) )
-import Data.Primitive.Internal.Compat ( mkNoRepType )
+import Data.Primitive.Internal.Compat ( isTrue#, mkNoRepType )
 
 -- | Boxed arrays
 data Array a = Array (Array# a) deriving ( Typeable )
@@ -106,7 +106,7 @@ unsafeThawArray (Array arr#)
 sameMutableArray :: MutableArray s a -> MutableArray s a -> Bool
 {-# INLINE sameMutableArray #-}
 sameMutableArray (MutableArray arr#) (MutableArray brr#)
-  = sameMutableArray# arr# brr#
+  = isTrue# (sameMutableArray# arr# brr#)
 
 -- | Copy a slice of an immutable array to a mutable array.
 copyArray :: PrimMonad m
@@ -165,4 +165,3 @@ instance (Typeable s, Typeable a) => Data (MutableArray s a) where
   toConstr _ = error "toConstr"
   gunfold _ _ = error "gunfold"
   dataTypeOf _ = mkNoRepType "Data.Primitive.Array.MutableArray"
-
diff --git a/Data/Primitive/ByteArray.hs b/Data/Primitive/ByteArray.hs
index 1cda612..8decb04 100644
--- a/Data/Primitive/ByteArray.hs
+++ b/Data/Primitive/ByteArray.hs
@@ -47,7 +47,7 @@ import GHC.Prim
 
 import Data.Typeable ( Typeable )
 import Data.Data ( Data(..) )
-import Data.Primitive.Internal.Compat ( mkNoRepType )
+import Data.Primitive.Internal.Compat ( isTrue#, mkNoRepType )
 
 -- | Byte arrays
 data ByteArray = ByteArray ByteArray# deriving ( Typeable )
@@ -99,7 +99,7 @@ mutableByteArrayContents (MutableByteArray arr#)
 sameMutableByteArray :: MutableByteArray s -> MutableByteArray s -> Bool
 {-# INLINE sameMutableByteArray #-}
 sameMutableByteArray (MutableByteArray arr#) (MutableByteArray brr#)
-  = sameMutableByteArray# arr# brr#
+  = isTrue# (sameMutableByteArray# arr# brr#)
 
 -- | Convert a mutable byte array to an immutable one without copying. The
 -- array should not be modified after the conversion.
@@ -263,4 +263,3 @@ instance Typeable s => Data (MutableByteArray s) where
   toConstr _ = error "toConstr"
   gunfold _ _ = error "gunfold"
   dataTypeOf _ = mkNoRepType "Data.Primitive.ByteArray.MutableByteArray"
-
diff --git a/Data/Primitive/Internal/Compat.hs b/Data/Primitive/Internal/Compat.hs
index 24b74bb..c0d3b75 100644
--- a/Data/Primitive/Internal/Compat.hs
+++ b/Data/Primitive/Internal/Compat.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE MagicHash #-}
+
 -- |
 -- Module      : Data.Primitive.Internal.Compat
 -- Copyright   : (c) Roman Leshchinskiy 2011-2012
@@ -9,13 +11,28 @@
 -- Compatibility functions
 --
 
-module Data.Primitive.Internal.Compat (mkNoRepType) where
+module Data.Primitive.Internal.Compat (
+    isTrue#
+  , mkNoRepType
+  ) where
 
 #if MIN_VERSION_base(4,2,0)
 import Data.Data (mkNoRepType)
 #else
 import Data.Data (mkNorepType)
+#endif
+
+#if MIN_VERSION_base(4,7,0)
+import GHC.Exts (isTrue#)
+#endif
 
+
+
+#if !MIN_VERSION_base(4,2,0)
 mkNoRepType = mkNorepType
 #endif
 
+#if !MIN_VERSION_base(4,7,0)
+isTrue# :: Bool -> Bool
+isTrue# b = b
+#endif
diff --git a/Data/Primitive/MutVar.hs b/Data/Primitive/MutVar.hs
index 0a4b1db..d3fee67 100644
--- a/Data/Primitive/MutVar.hs
+++ b/Data/Primitive/MutVar.hs
@@ -25,6 +25,7 @@ module Data.Primitive.MutVar (
 import Control.Monad.Primitive ( PrimMonad(..), primitive_ )
 import GHC.Prim ( MutVar#, sameMutVar#, newMutVar#,
                   readMutVar#, writeMutVar#, atomicModifyMutVar# )
+import Data.Primitive.Internal.Compat ( isTrue# )
 import Data.Typeable ( Typeable )
 
 -- | A 'MutVar' behaves like a single-element mutable array associated
@@ -33,7 +34,7 @@ data MutVar s a = MutVar (MutVar# s a)
   deriving ( Typeable )
 
 instance Eq (MutVar s a) where
-  MutVar mva# == MutVar mvb# = sameMutVar# mva# mvb#
+  MutVar mva# == MutVar mvb# = isTrue# (sameMutVar# mva# mvb#)
 
 -- | Create a new 'MutVar' with the specified initial value
 newMutVar :: PrimMonad m => a -> m (MutVar (PrimState m) a)
diff --git a/Data/Primitive/Types.hs b/Data/Primitive/Types.hs
index 7eb3f2e..ffd2cb4 100644
--- a/Data/Primitive/Types.hs
+++ b/Data/Primitive/Types.hs
@@ -42,20 +42,20 @@ import GHC.Prim
 
 import Data.Typeable ( Typeable )
 import Data.Data ( Data(..) )
-import Data.Primitive.Internal.Compat ( mkNoRepType )
+import Data.Primitive.Internal.Compat ( isTrue#, mkNoRepType )
 
 -- | A machine address
 data Addr = Addr Addr# deriving ( Typeable )
 
 instance Eq Addr where
-  Addr a# == Addr b# = eqAddr# a# b#
-  Addr a# /= Addr b# = neAddr# a# b#
+  Addr a# == Addr b# = isTrue# (eqAddr# a# b#)
+  Addr a# /= Addr b# = isTrue# (neAddr# a# b#)
 
 instance Ord Addr where
-  Addr a# > Addr b# = gtAddr# a# b#
-  Addr a# >= Addr b# = geAddr# a# b#
-  Addr a# < Addr b# = ltAddr# a# b#
-  Addr a# <= Addr b# = leAddr# a# b#
+  Addr a# > Addr b# = isTrue# (gtAddr# a# b#)
+  Addr a# >= Addr b# = isTrue# (geAddr# a# b#)
+  Addr a# < Addr b# = isTrue# (ltAddr# a# b#)
+  Addr a# <= Addr b# = isTrue# (leAddr# a# b#)
 
 instance Data Addr where
   toConstr _ = error "toConstr"
@@ -181,4 +181,3 @@ derivePrim(Char, C#, sIZEOF_CHAR, aLIGNMENT_CHAR,
 derivePrim(Addr, Addr, sIZEOF_PTR, aLIGNMENT_PTR,
            indexAddrArray#, readAddrArray#, writeAddrArray#, setAddrArray#,
            indexAddrOffAddr#, readAddrOffAddr#, writeAddrOffAddr#, setAddrOffAddr#)
-




More information about the ghc-commits mailing list