| I agree. In fact, I would be most happy with a function getRandom :: IO
| Double that returns a random number between 0 and 1.
Good point. When trying to develop a testbed for the library of sorting
routines I found the library Random completely unusable. There are
essentially two reasons:
a) I required both random `Int's, `Integer's and `Double's.
b) If a test input reveals an error in the code, one should be able
to reproduce the run which in turn requires that the initial seed
is available.
The following signature seems quite reasonable to me.
type Seed = Int
getSeed :: IO Seed
setSeed :: Seed -> IO ()
randomInt :: IO Int
randomInteger :: IO Integer
randomDouble :: IO Double
`getSeed' obtains a seed in some system-dependent manner. `setSeed'
sets the seed for the `randomType' functions. The latter functions all
use the same internal seed to be able to produce good random data. [One
could perhaps invent a new class to standardize the last three
functions but I don't know whether this is worth the effort].
Additionally, one could supply functions which take and return the seed
explicitly.
randInt :: Seed -> (Int, Seed)
randInteger :: Seed -> (Integer, Seed)
randDouble :: Seed -> (Double, Seed)
Cheers, Ralf