[commit: packages/array] master: Restore compatibility with GHC 7.10 (3b750b3)
git at git.haskell.org
git at git.haskell.org
Tue Mar 10 08:49:19 UTC 2015
Repository : ssh://git@git.haskell.org/array
On branch : master
Link : http://git.haskell.org/packages/array.git/commitdiff/3b750b3eeb02051520f1b149f0171baba951f544
>---------------------------------------------------------------
commit 3b750b3eeb02051520f1b149f0171baba951f544
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date: Tue Mar 10 09:34:10 2015 +0100
Restore compatibility with GHC 7.10
This adds CPP guards around the changes in
c9f207182d4c0a4fcfaaabffb5ed759b99913bb5
>---------------------------------------------------------------
3b750b3eeb02051520f1b149f0171baba951f544
Data/Array/Base.hs | 28 ++++++++++++++++++++++++++++
Data/Array/IO/Internals.hs | 19 +++++++++++++++++++
Data/Array/ST.hs | 15 +++++++++++----
3 files changed, 58 insertions(+), 4 deletions(-)
diff --git a/Data/Array/Base.hs b/Data/Array/Base.hs
index d632e10..ab41c0b 100644
--- a/Data/Array/Base.hs
+++ b/Data/Array/Base.hs
@@ -1390,7 +1390,11 @@ freeze marr = do
-- use the safe array creation function here.
return (listArray (l,u) es)
+#if __GLASGOW_HASKELL__ >= 711
freezeSTUArray :: STUArray s i e -> ST s (UArray i e)
+#else
+freezeSTUArray :: Ix i => STUArray s i e -> ST s (UArray i e)
+#endif
freezeSTUArray (STUArray l u n marr#) = ST $ \s1# ->
case sizeofMutableByteArray# marr# of { n# ->
case newByteArray# n# s1# of { (# s2#, marr'# #) ->
@@ -1465,7 +1469,11 @@ thaw arr = case bounds arr of
| i <- [0 .. n - 1]]
return marr
+#if __GLASGOW_HASKELL__ >= 711
thawSTUArray :: UArray i e -> ST s (STUArray s i e)
+#else
+thawSTUArray :: Ix i => UArray i e -> ST s (STUArray s i e)
+#endif
thawSTUArray (UArray l u n arr#) = ST $ \s1# ->
case sizeofByteArray# arr# of { n# ->
case newByteArray# n# s1# of { (# s2#, marr# #) ->
@@ -1525,7 +1533,11 @@ unsafeThaw :: (Ix i, IArray a e, MArray b e m) => a i e -> m (b i e)
unsafeThaw = thaw
{-# INLINE unsafeThawSTUArray #-}
+#if __GLASGOW_HASKELL__ >= 711
unsafeThawSTUArray :: UArray i e -> ST s (STUArray s i e)
+#else
+unsafeThawSTUArray :: Ix i => UArray i e -> ST s (STUArray s i e)
+#endif
unsafeThawSTUArray (UArray l u n marr#) =
return (STUArray l u n (unsafeCoerce# marr#))
@@ -1535,7 +1547,11 @@ unsafeThawSTUArray (UArray l u n marr#) =
#-}
{-# INLINE unsafeThawIOArray #-}
+#if __GLASGOW_HASKELL__ >= 711
unsafeThawIOArray :: Arr.Array ix e -> IO (IOArray ix e)
+#else
+unsafeThawIOArray :: Ix ix => Arr.Array ix e -> IO (IOArray ix e)
+#endif
unsafeThawIOArray arr = stToIO $ do
marr <- ArrST.unsafeThawSTArray arr
return (IOArray marr)
@@ -1544,7 +1560,11 @@ unsafeThawIOArray arr = stToIO $ do
"unsafeThaw/IOArray" unsafeThaw = unsafeThawIOArray
#-}
+#if __GLASGOW_HASKELL__ >= 711
thawIOArray :: Arr.Array ix e -> IO (IOArray ix e)
+#else
+thawIOArray :: Ix ix => Arr.Array ix e -> IO (IOArray ix e)
+#endif
thawIOArray arr = stToIO $ do
marr <- ArrST.thawSTArray arr
return (IOArray marr)
@@ -1553,7 +1573,11 @@ thawIOArray arr = stToIO $ do
"thaw/IOArray" thaw = thawIOArray
#-}
+#if __GLASGOW_HASKELL__ >= 711
freezeIOArray :: IOArray ix e -> IO (Arr.Array ix e)
+#else
+freezeIOArray :: Ix ix => IOArray ix e -> IO (Arr.Array ix e)
+#endif
freezeIOArray (IOArray marr) = stToIO (ArrST.freezeSTArray marr)
{-# RULES
@@ -1561,7 +1585,11 @@ freezeIOArray (IOArray marr) = stToIO (ArrST.freezeSTArray marr)
#-}
{-# INLINE unsafeFreezeIOArray #-}
+#if __GLASGOW_HASKELL__ >= 711
unsafeFreezeIOArray :: IOArray ix e -> IO (Arr.Array ix e)
+#else
+unsafeFreezeIOArray :: Ix ix => IOArray ix e -> IO (Arr.Array ix e)
+#endif
unsafeFreezeIOArray (IOArray marr) = stToIO (ArrST.unsafeFreezeSTArray marr)
{-# RULES
diff --git a/Data/Array/IO/Internals.hs b/Data/Array/IO/Internals.hs
index a7883f3..c934cc5 100644
--- a/Data/Array/IO/Internals.hs
+++ b/Data/Array/IO/Internals.hs
@@ -34,6 +34,9 @@ import Control.Monad.ST ( RealWorld, stToIO )
import Foreign.Ptr ( Ptr, FunPtr )
import Foreign.StablePtr ( StablePtr )
+#if __GLASGOW_HASKELL__ < 711
+import Data.Ix
+#endif
import Data.Array.Base
import GHC.IOArray (IOArray(..))
@@ -374,7 +377,11 @@ castIOUArray (IOUArray marr) = stToIO $ do
return (IOUArray marr')
{-# INLINE unsafeThawIOUArray #-}
+#if __GLASGOW_HASKELL__ >= 711
unsafeThawIOUArray :: UArray ix e -> IO (IOUArray ix e)
+#else
+unsafeThawIOUArray :: Ix ix => UArray ix e -> IO (IOUArray ix e)
+#endif
unsafeThawIOUArray arr = stToIO $ do
marr <- unsafeThawSTUArray arr
return (IOUArray marr)
@@ -383,7 +390,11 @@ unsafeThawIOUArray arr = stToIO $ do
"unsafeThaw/IOUArray" unsafeThaw = unsafeThawIOUArray
#-}
+#if __GLASGOW_HASKELL__ >= 711
thawIOUArray :: UArray ix e -> IO (IOUArray ix e)
+#else
+thawIOUArray :: Ix ix => UArray ix e -> IO (IOUArray ix e)
+#endif
thawIOUArray arr = stToIO $ do
marr <- thawSTUArray arr
return (IOUArray marr)
@@ -393,14 +404,22 @@ thawIOUArray arr = stToIO $ do
#-}
{-# INLINE unsafeFreezeIOUArray #-}
+#if __GLASGOW_HASKELL__ >= 711
unsafeFreezeIOUArray :: IOUArray ix e -> IO (UArray ix e)
+#else
+unsafeFreezeIOUArray :: Ix ix => IOUArray ix e -> IO (UArray ix e)
+#endif
unsafeFreezeIOUArray (IOUArray marr) = stToIO (unsafeFreezeSTUArray marr)
{-# RULES
"unsafeFreeze/IOUArray" unsafeFreeze = unsafeFreezeIOUArray
#-}
+#if __GLASGOW_HASKELL__ >= 711
freezeIOUArray :: IOUArray ix e -> IO (UArray ix e)
+#else
+freezeIOUArray :: Ix ix => IOUArray ix e -> IO (UArray ix e)
+#endif
freezeIOUArray (IOUArray marr) = stToIO (freezeSTUArray marr)
{-# RULES
diff --git a/Data/Array/ST.hs b/Data/Array/ST.hs
index 31e1ed0..0a8ff0d 100644
--- a/Data/Array/ST.hs
+++ b/Data/Array/ST.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
{-# LANGUAGE RankNTypes #-}
-----------------------------------------------------------------------------
-- |
@@ -37,8 +38,11 @@ import GHC.Arr ( STArray, Array, unsafeFreezeSTArray )
-- the array before returning it - it uses 'unsafeFreeze' internally, but
-- this wrapper is a safe interface to that function.
--
-runSTArray :: (forall s . ST s (STArray s i e))
- -> Array i e
+#if __GLASGOW_HASKELL__ >= 711
+runSTArray :: (forall s . ST s (STArray s i e)) -> Array i e
+#else
+runSTArray :: Ix i => (forall s . ST s (STArray s i e)) -> Array i e
+#endif
runSTArray st = runST (st >>= unsafeFreezeSTArray)
-- | A safe way to create and work with an unboxed mutable array before
@@ -47,8 +51,11 @@ runSTArray st = runST (st >>= unsafeFreezeSTArray)
-- 'unsafeFreeze' internally, but this wrapper is a safe interface to
-- that function.
--
-runSTUArray :: (forall s . ST s (STUArray s i e))
- -> UArray i e
+#if __GLASGOW_HASKELL__ >= 711
+runSTUArray :: (forall s . ST s (STUArray s i e)) -> UArray i e
+#else
+runSTUArray :: Ix i => (forall s . ST s (STUArray s i e)) -> UArray i e
+#endif
runSTUArray st = runST (st >>= unsafeFreezeSTUArray)
More information about the ghc-commits
mailing list