Random Number Update

Adam Bergmark adam at bergmark.nl
Tue Jan 24 15:18:16 UTC 2017


On Tue, 24 Jan 2017 at 14:36 Dominic Steinitz <dominic at steinitz.org> wrote:

> I wanted to give an update on the status of random numbers in Haskell.
>
>  1. It is well known that the random number generator package
>     https://hackage.haskell.org/package/random gives unexpected
>     results.
>  2. Most people do *not* use it. I believe
>     https://hackage.haskell.org/package/mwc-random is a popular choice
>     but developers are free to use e.g. Mersenne Twister, PCG
>     (Permuted Congruential Generator), TF (ThreeFish) and many others.
>  3. Approximately 2 years, I made a proposal to replace the algorithm
>     within random (https://hackage.haskell.org/package/random) with
>     that used by tf-random
>     (https://hackage.haskell.org/package/tf-random) which is used by
>     QuickCheck. In summary, the response to this was that someone
>     should do more research with the result that nothing happened.
>  4. In the meantime, random
>     (https://hackage.haskell.org/package/random) is *no longer* a core
>     library. It's just a library with the same status as
>     e.g. mwc-random. However, it has one difference: it uses the name
>     for its module: "System.Random". Other RNGs use
>     "System.Random.MWC", "System.Random.PCG", "System.Random.Mersenne"
>     etc.
>
> As a maintainer of random
> (https://hackage.haskell.org/package/random), my proposal now is to
> deprecate all of it.
>
> I am not clear what the policy is on namespace usage. Could every RNG
> use the module name "System.Random"? Or is this somehow reserved? If
> the latter then I propose that *nothing* uses this name and that all
> RNGs should add a suffix indicating which algorithm they use.
>

They *could* use the same namespace but I don't recommend it. If someone
depends on two of these packages they would have to use PackageImports.
Tools such as doctest break if a package db has module conflicts, even if
only one of the packages is listed as a dependency.

Cheers,
Adam


> I note that the Haskell Platform contains tf-random so users of this
> will still be able to generate (better) random numbers.
>
> If someone comes along in the future, as I hope they do, and
> implements e.g. Guy Steele's splitmix algorithm then this can occupy
> the name "System.Random.Splitmix" and have the package name
> "random-splitmix".
>
> The advantages of doing this are:
>
>  1. Neophyte (and experienced) Haskellers do not accidentally use an
>     RNG which gives unexpected results.
>  2. No-one will any longer be able to write blogs or papers about this
>     embarrassing aspect of Haskell.
>
> I believe the co-maintainer of random
> (https://hackage.haskell.org/package/random), Carter Schonwald, has a
> different view on this matter but it is best he speaks for himself
> rather than me imperfectly trying to reflect his thinking.
>
> Dominic Steinitz
> dominic at steinitz.org
> http://idontgetoutmuch.wordpress.com
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20170124/952d0aeb/attachment-0001.html>


More information about the Libraries mailing list