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

Henning Thielemann schlepptop at
Wed Sep 15 11:20:30 EDT 2010

Thomas DuBuisson schrieb:
> 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.
> Period of discussion: Till October 8 (3.5 weeks, ending just over 1
> week after ICFP)

I assume that there is more code that uses RandomGen in constraints than
code that defines instances, thus the split of the split class might
look like:

class StraightRandomGen g where :: g -> (Int, g)
  System.Random.genRange :: g -> (Int, Int)

class StraightRandomGen g => RandomGen g where
  System.Random.split :: g -> (g, g)

All existing code that uses RandomGen in constraints would remain valid
this way.

More information about the Libraries mailing list