Ralf Hinze <[EMAIL PROTECTED]> writes:
> 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
This isn't sufficient for the random-number generator distributed with
Hugs (L'Ecuyer's transliterated by Augusstsson and modified by Reid.)
(Just yesterday I hacked this library to return a "seed" with each
number so that the stream can be replayed from any point.) For it
you'll need
data Seed = Seed Int Int
In general, having the seed be an Int for the non-monadic functions:
> randInt :: Seed -> (Int, Seed)
> randInteger :: (Integer, Integer) -> Seed -> (Integer, Seed)
> randDouble :: Seed -> (Double, Seed)
would seem to limit you to small-period random-number generators.
This suggest a Seed type with a constructor like:
mkSeed :: Int -> Seed
If you want to be able to replay a stream from an arbitrary point from
another process you'll need some way communicate the seed. Perhaps:
instance Show Seed
instance Read Seed
I just made Seed non-abstract (and an instance of Show), but this
probably isn't the right approach for a standard.
mike