From: malcolm Date: Thu, 19 Dec 2002 22:04:41 +0000 (+0000) Subject: [project @ 2002-12-19 22:04:41 by malcolm] X-Git-Tag: nhc98-1-18-release~773 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=cbbe807abe8e8a5a40961d08b66050b19148fe50;p=ghc-base.git [project @ 2002-12-19 22:04:41 by malcolm] Make it work with nhc98. --- diff --git a/System/Random.hs b/System/Random.hs index 47e3a48..129e5a9 100644 --- a/System/Random.hs +++ b/System/Random.hs @@ -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