[project @ 2002-09-30 14:31:02 by ross]
authorross <unknown>
Mon, 30 Sep 2002 14:31:03 +0000 (14:31 +0000)
committerross <unknown>
Mon, 30 Sep 2002 14:31:03 +0000 (14:31 +0000)
Portability tweak.

Data/Array/Diff.hs
Data/Array/IO.hs
Data/List.hs
System/Random.hs

index 515c243..6a598f1 100644 (file)
@@ -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''
index 0a2d7de..6a608fd 100644 (file)
@@ -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
index a6bff9b..63277f3 100644 (file)
@@ -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
index 32ab0ae..6662549 100644 (file)
@@ -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 ->