[mercury-users] a typeclassful random.m

doug.auclair at logicaltypes.com doug.auclair at logicaltypes.com
Mon Feb 19 11:42:14 AEDT 2007


Dear All, Julian wrote:

> The attached random.m implements that module, and rand_test.m
> uses it to print random ints and floats from a tausworthe3 PRNG
> seeded from /dev/urandom
> 
> It offers these base typeclasses:
> 
>  :- typeclass prng(T, S) <= ((T -> S), (S -> T)) where [
> [...]
>  :- typeclass io_prng(T, S) <= ((T -> S), (S -> T)) where [

It looks like applications are using the tausworthe3 (I've heard: "the best
benchmarked RNG") with a typeclass wrapper (qcheck2 at 
logicaltypes.com typeclassed the provided RNG as well, off the
recommendation from qcheck in extras/), and  I'm currently 
developing another app that needs pretty good  (pseudo) 
randomness, so perhaps this is a good time to move 
a RNG typeclass into the standard library (replacing the
current random module with it) and provide tausworthe3 as the
default (or supplied example) instance?  It seems like so much
effort is going into each application development process to 
come up with nearly identical (but still different) protocols, that 
it warrants guidance from the Melbourne Mercury team as a
standard library module. I haven't yet reviewed the code, but I 
also like support predicates to the protocol, particularly 
rand_float, giving values in the range [0, 1).  rand_float is, of
course, derivative, but it's very much a labour-saving device 
for the work I need to do.

With the above in mind, I am switching my apps (qcheck2 and
my current project) to use the (acknowledged moving target)
typeclassed tausworthe3 PRNG implementation: the module
for which will go into my utility set until the (I hope very soon)
incorporation of it into the standard library.

Sincerely,
Doug Auclair


--------------------------------------------------------------------------
mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the users mailing list