Proposal: Move 'split' into a separate class in System.Random

Simon Peyton-Jones simonpj at
Thu Oct 7 04:00:46 EDT 2010

| > The "split" routine in the RandomGen seems to be a sore spot for some
| > people and is perceived to have few users (even as a percentage of
| > RandomGen users).  I propose:
| >
| > 1) Making a class "SplittableGen":
| >
| > class SplittableGen g where
| >   split :: g -> (g, g)
| >
| > 2) (re)moving the "split" routine from the RandomGen class.
| >
| > See ticket 4314 [1] for the patch.

The design, of having two classes, seems nearly right.  The nit is that surely RandomGen should be a superclass of SplittableGen?  I don't want to bloat my contexts too much.

The main issue is one of backward compatibility etc.  Personally I'm ok with changing APIs at major releases, but others should yell if not.  Presumably you'll still get the old API if you 'import Random' from the H98 package.


More information about the Libraries mailing list