On 04-Feb-2000, Matt Harden <[EMAIL PROTECTED]> wrote:
> > 
> > > class RandomGen g where
> > >    next :: g -> (Int, g)
> > >    split :: g -> (g, g)
> > >    genRange :: g -> (Int, Int)
> > >    genRange _ = (minBound, maxBound)
> 
> Simon, do you think we could have the *optional* genRange described
> above?  If that approach is chosen, then the changes to GHC and Hugs
> are rather painless.

I think that's probably the best thing to do in the long run.
And in the short term, it may well be the easiest thing to do,
at least as far as ghc and Hugs are concerned.

What about the other Haskell implementations?
Do any of them implement the Haskell 98 Random module yet?
If so, do they generate the full range minBound .. maxBound,
or do they generate something different?

Note that the optional genRange method is only optional
as far as the implementor of a RandomGen instance is concerned.
For the user of a RandomGen, it is not optional, in the sense that
if we add the genRange method, then users who want code using
that class to have the correct behaviour will have to make use
of that new method.  However, the most common uses of the RandomGen
class would be indirect, via the Random class, so probably there
is not much code which would depend on this.

Does anyone have any code which uses the current RandomGen interface,
making the assumption that the random number generator returns the full
range of Int?  I guess that is fairly unlikely, not only for the reason
mentioned above, but also because such code would not work correctly
with the current Hugs/ghc implementations.  If my guess is correct,
then I suppose there is no real advantage in sticking with a minimal
clarification of the current Haskell 98 specification, and it would be
better to add the genRange method as suggested above.

-- 
Fergus Henderson <[EMAIL PROTECTED]>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger [EMAIL PROTECTED]        |     -- the last words of T. S. Garp.

Reply via email to