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

Duncan Coutts duncan.coutts at googlemail.com
Wed Sep 15 10:17:53 EDT 2010


On 15 September 2010 00:44, Thomas DuBuisson <thomas.dubuisson at gmail.com> wrote:
> 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 support this change.

The rationale is that while split is very useful (e.g. in pure lazy
code), there are many PRNGs that are not splitable. Thus simply
splitting the existing functions into two classes allows many common
PRNGs to be instances of the main random gen type class without
forcing them to implement bogus split functions.

I do not think we need to go as far as Bryan suggests and provide
estimates of remaining entropy. If there is demand for tracking
entropy then we can do it separately.

This change is fairly minimal as it only changes type class names in
type signatures, not function names, function parameters or module
imports. We should however consider this change in the context of the
other proposals for the random class. If however those changes cannot
be agreed, this smaller change could go through on its own, IMHO.

Duncan


More information about the Libraries mailing list