[Haskell-cafe] System.Random.Mersenne - no randomR variants

Don Stewart dons at galois.com
Mon Oct 5 16:28:20 EDT 2009


p.f.moore:
> I notice that System.Random.Mersenne has no randomR variants. Is there
> a reason for this, or is it just an oversight? It makes porting code
> from System.Random a little more complicated than it needs to be. I
> know it's possible to write a function mapping a Double (or other
> value, as appropriate) to a range, effectively replacing randomR, but
> it's fiddly to get the edge cases right. A standard implementation
> would be helpful.

Basically, to use the type class interface defined in System.Random, you
will suffer a 100x decrease in performance, as  the instances all
convert via Integer. 

Rather than give people a surprise, I chose not to implement that
interface.

-- Don


More information about the Haskell-Cafe mailing list