
10 Oct
2010
10 Oct
'10
10:16 a.m.
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