From: ross Date: Mon, 30 Sep 2002 14:31:03 +0000 (+0000) Subject: [project @ 2002-09-30 14:31:02 by ross] X-Git-Tag: nhc98-1-18-release~833 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=00ad3706672e7d739be53af26c345500e44b0d70;p=ghc-base.git [project @ 2002-09-30 14:31:02 by ross] Portability tweak. --- diff --git a/Data/Array/Diff.hs b/Data/Array/Diff.hs index 515c243..6a598f1 100644 --- a/Data/Array/Diff.hs +++ b/Data/Array/Diff.hs @@ -80,7 +80,7 @@ import Data.Int ( Int8, Int16, Int32, Int64 ) import Data.Word ( Word, Word8, Word16, Word32, Word64) import System.IO.Unsafe ( unsafePerformIO ) -import Control.Concurrent ( MVar, newMVar, takeMVar, putMVar, readMVar ) +import Control.Concurrent.MVar ( MVar, newMVar, takeMVar, putMVar, readMVar ) ------------------------------------------------------------------------ -- Diff array types. @@ -307,7 +307,8 @@ boundsDiffArray a = do freezeDiffArray :: (MArray a e IO, Ix ix) => a ix e -> IO (IOToDiffArray a ix e) -freezeDiffArray a | (l,u) <- bounds a = do +freezeDiffArray a = case bounds a of + (l,u) -> do a' <- newArray_ (l,u) sequence_ [unsafeRead a i >>= unsafeWrite a' i | i <- [0 .. rangeSize (l,u) - 1]] var <- newMVar (Current a') @@ -338,7 +339,8 @@ thawDiffArray :: (MArray a e IO, Ix ix) thawDiffArray a = do d <- readMVar (varDiffArray a) case d of - Current a' | (l,u) <- bounds a' -> do + Current a' -> case bounds a' of + (l,u) -> do a'' <- newArray_ (l,u) sequence_ [unsafeRead a' i >>= unsafeWrite a'' i | i <- [0 .. rangeSize (l,u) - 1]] return a'' diff --git a/Data/Array/IO.hs b/Data/Array/IO.hs index 0a2d7de..6a608fd 100644 --- a/Data/Array/IO.hs +++ b/Data/Array/IO.hs @@ -19,9 +19,7 @@ module Data.Array.IO ( -- * @IO@ arrays with unboxed elements IOUArray, -- instance of: Eq, Typeable -#ifdef __GLASGOW_HASKELL__ castIOUArray, -- :: IOUArray i a -> IO (IOUArray i b) -#endif -- * Overloaded mutable array interface module Data.Array.MArray, @@ -43,6 +41,7 @@ import Data.Dynamic #ifdef __HUGS__ import Hugs.IOArray +import Hugs.IOExts ( unsafeCoerce ) import Data.Array.Storable #endif @@ -74,6 +73,9 @@ instance MArray IOArray e IO where unsafeWrite = unsafeWriteIOArray type IOUArray = StorableArray + +castIOUArray :: IOUArray i a -> IO (IOUArray i b) +castIOUArray marr = return (unsafeCoerce marr) #endif /* __HUGS__ */ iOArrayTc :: TyCon diff --git a/Data/List.hs b/Data/List.hs index a6bff9b..63277f3 100644 --- a/Data/List.hs +++ b/Data/List.hs @@ -161,19 +161,15 @@ findIndex p = listToMaybe . findIndices p findIndices :: (a -> Bool) -> [a] -> [Int] -#ifdef USE_REPORT_PRELUDE +#if defined(USE_REPORT_PRELUDE) || !defined(__GLASGOW_HASKELL__) findIndices p xs = [ i | (x,i) <- zip xs [0..], p x] #else -#ifdef __HUGS__ -findIndices p xs = [ i | (x,i) <- zip xs [0..], p x] -#else -- Efficient definition findIndices p ls = loop 0# ls where loop _ [] = [] loop n (x:xs) | p x = I# n : loop (n +# 1#) xs | otherwise = loop (n +# 1#) xs -#endif /* __HUGS__ */ #endif /* USE_REPORT_PRELUDE */ isPrefixOf :: (Eq a) => [a] -> [a] -> Bool diff --git a/System/Random.hs b/System/Random.hs index 32ab0ae..6662549 100644 --- a/System/Random.hs +++ b/System/Random.hs @@ -51,8 +51,7 @@ import Data.IORef import Numeric ( readDec ) #ifdef __GLASGOW_HASKELL__ -import GHC.Show ( showSignedInt, showSpace ) -import GHC.IOBase ( unsafePerformIO, stToIO ) +import GHC.IOBase ( stToIO ) import System.Time ( getClockTime, ClockTime(..) ) #endif @@ -145,21 +144,11 @@ instance RandomGen StdGen where next = stdNext split = stdSplit -#ifdef __GLASGOW_HASKELL__ -instance Show StdGen where - showsPrec p (StdGen s1 s2) = - showSignedInt p s1 . - showSpace . - showSignedInt p s2 -#endif - -#ifdef __HUGS__ instance Show StdGen where showsPrec p (StdGen s1 s2) = showsPrec p s1 . showChar ' ' . showsPrec p s2 -#endif instance Read StdGen where readsPrec _p = \ r ->