Personally I have only one gripe with the Random class in Standard Haskell;
this is that it provides too much functionality.  
In general I think you can only have two of the following 3:
(1) good random numbers 
(2) speed
(3) small state
For example the Mersenne Twister is very very good and fast but has huge
state (several kilobytes), see
   http://www.math.keio.ac.jp/~matumoto/emt.html 
and there is even a Haskell implementation.

GHC's current generator is quite good (it passes the Diehard test, which
makes it better than Java's, but on the other hand I wouldn't trust it for more
than about 2^40 integers), but also pretty slow, even if you don't count
the fact that at each step it has to box up a tuple containing the state.

But the current Haskell implementation forces you to have small state, and
so you must have a slow generator.  You don't really need this.  In most
applications, if you need to get at the state at all, you only need to
do it pretty rarely.  The following interface would suffice.  I agree it
would be slightly yucky if you wanted to create lots of random values in
a structure like a tree, because every function generating a substructure
would have to be an action.  In GHC or Hugs, it would be neater if most of these 
functions were ST RandomGen or something like that.
   
random :: IO a -- for all things in class Random, eg integers, booleans
randomR (as for current interface) to generate ranges
-- only experts really need to look below this line.

random = random' systemRandomGen
random' :: RandomGen -> IO a

type RandomGen -- holds state for random generator.
systemRandomGen :: RandomGen -- default generator 

type RandomGenContents -- encodes state of random generator

instance Read RandomGenContents
instance Show RandomGenContents 

setRandomGen :: RandomGenContents -> RandomGen -> IO()
getRandomGen :: RandomGen -> IO RandomGenContents

makeRandomGenContents :: Integer -> RandomGenContents -- deterministic
makeRandomGen :: RandomGenContents -> IO RandomGen

Reply via email to