X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=System%2FRandom.hs;h=98420e186cf2bbe1e9763a4531cf36f3194f60f2;hb=d539a9457e2c79a9f13744d073d3f253ea2fb33e;hp=129e5a940acf5ceab0ad84727859902266b13931;hpb=cbbe807abe8e8a5a40961d08b66050b19148fe50;p=ghc-base.git diff --git a/System/Random.hs b/System/Random.hs index 129e5a9..98420e1 100644 --- a/System/Random.hs +++ b/System/Random.hs @@ -46,6 +46,7 @@ import Prelude #ifdef __NHC__ import CPUTime ( getCPUTime ) +import Foreign.Ptr ( Ptr, nullPtr ) #else import System.CPUTime ( getCPUTime ) import System.Time ( getClockTime, ClockTime(..) ) @@ -55,23 +56,19 @@ import System.IO.Unsafe ( unsafePerformIO ) import Data.IORef import Numeric ( readDec ) -#ifdef __GLASGOW_HASKELL__ -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 +foreign import ccall "time.h time" readtime :: Ptr () -> IO Int getClockTime :: IO ClockTime -getClockTime = do t <- readtime 0; return (TOD (toInteger t) ()) +getClockTime = do t <- readtime nullPtr; return (TOD (toInteger t) ()) #endif {- $intro -The "Random" library deals with the common task of pseudo-random +This library deals with the common task of pseudo-random number generation. The library makes it possible to generate repeatable results, by starting with a specified initial random number generator; or to get different results on each run by using the @@ -120,8 +117,8 @@ class RandomGen g where -- default mathod genRange g = (minBound,maxBound) -{- |The "Random" library provides one instance of 'RandomGen', the abstract data -type 'StdGen'. +{- |The "System.Random" library provides one instance of 'RandomGen', the +abstract data type 'StdGen'. The result of repeatedly using next should be at least as statistically robust as the /Minimal Standard Random Number Generator/ described by