Portability tweak.
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.
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')
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''
-- * @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,
#ifdef __HUGS__
import Hugs.IOArray
+import Hugs.IOExts ( unsafeCoerce )
import Data.Array.Storable
#endif
unsafeWrite = unsafeWriteIOArray
type IOUArray = StorableArray
+
+castIOUArray :: IOUArray i a -> IO (IOUArray i b)
+castIOUArray marr = return (unsafeCoerce marr)
#endif /* __HUGS__ */
iOArrayTc :: TyCon
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
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
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 ->