Commit 3b750b3e authored by Herbert Valerio Riedel's avatar Herbert Valerio Riedel 🕺

Restore compatibility with GHC 7.10

This adds CPP guards around the changes in
c9f20718
parent c585b1f1
......@@ -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
......
......@@ -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
......
{-# 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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment