[project @ 2002-12-19 22:04:41 by malcolm]
authormalcolm <unknown>
Thu, 19 Dec 2002 22:04:41 +0000 (22:04 +0000)
committermalcolm <unknown>
Thu, 19 Dec 2002 22:04:41 +0000 (22:04 +0000)
Make it work with nhc98.

System/Random.hs

index 47e3a48..129e5a9 100644 (file)
@@ -44,8 +44,12 @@ module System.Random
 
 import Prelude
 
+#ifdef __NHC__
+import CPUTime         ( getCPUTime )
+#else
 import System.CPUTime  ( getCPUTime )
 import System.Time     ( getClockTime, ClockTime(..) )
+#endif
 import Data.Char       ( isSpace, chr, ord )
 import System.IO.Unsafe ( unsafePerformIO )
 import Data.IORef
@@ -55,6 +59,16 @@ import Numeric               ( readDec )
 import GHC.IOBase      ( stToIO )
 #endif
 
+-- The standard nhc98 implementation of Time.ClockTime does not match
+-- the extended one expected in this module, so we lash-up a quick
+-- replacement here.
+#ifdef __NHC__
+data ClockTime = TOD Integer ()
+foreign import ccall "time.h time" readtime :: Int -> IO Int
+getClockTime :: IO ClockTime
+getClockTime = do t <- readtime 0;  return (TOD (toInteger t) ())
+#endif
+
 {- $intro
 
 The "Random" library deals with the common task of pseudo-random
@@ -223,7 +237,7 @@ class Random a where
 
   -- |Default methods  
   randoms  :: RandomGen g => g -> [a]
-  randoms  g      = x : randoms g' where (x,g') = random g
+  randoms  g      = (\(x,g') -> x : randoms g') (random g)
 
   randomRs :: RandomGen g => (a,a) -> g -> [a]
   randomRs ival g = x : randomRs ival g' where (x,g') = randomR ival g