Proposal: Move 'split' into a separate class in System.Random
Jan-Willem Maessen
jmaessen at alum.mit.edu
Mon Oct 11 11:26:51 EDT 2010
On Sat, Oct 9, 2010 at 11:02 AM, Thomas DuBuisson
<thomas.dubuisson at gmail.com> wrote:
> All,
> I have updated the ticket/patch for this proposal [1]. It seems the
> community has agreed on
>
>> class RandomGen g where
>> next :: g -> (Int, g)
>> genRange :: g -> (Int,Int)
>> genRange _ = (minBound, maxBound)
>
>> class (RandomGen g) => SplittableGen g where
>> split :: g -> (g, g)
>
> Notice SPJs good catch that SplittableGen should be constrained by
> RandomGen is there (lacking discussion, but its hard to imagine
> objection). I'm not sure what you, Jan, mean by removing Read and
> Show constraints as I don't see any.
I was mis-remembering the following as a class constraint on RandomGen:
data StdGen = ... -- Abstract
instance RandomGen StdGen where ...
instance Read StdGen where ...
instance Show StdGen where ...
(http://www.haskell.org/onlinelibrary/random.html)
This makes it hard to impossible to implement splitting of StdGen both
efficiently and correctly.
-Jan
More information about the Libraries
mailing list