Proposal: Generalize the RandomGen and Random classes

Thomas DuBuisson thomas.dubuisson at gmail.com
Sun Oct 10 10:16:02 EDT 2010


> Couldn't we just have
>
>>   class RandomGen g where
>>     next :: g -> (Bool, g)
>
> where the generator can be internally based on Word32, Word64 or
> whatever is appropriate? Then the Random methods compose the bits to
> Ints, Integers, Word16, Float etc. but some optimizer rules take care of
> that the bit representation is actually not needed in common cases?

I think you're dreaming of an imaginary optimizer of supreme power.  I
don't see how RULES can ever get me from "next :: g -> (Bool, g)" to
an efficient "nonce :: g -> (ByteString, g)".  Obviously I would be
thrilled to be proven wrong.

Cheers,
Thomas


More information about the Libraries mailing list