[Haskell-cafe] Mersenne-random and standard random API

Ertugrul Söylemez es at ertes.de
Thu Feb 9 09:28:02 CET 2012

Yves Parès <yves.pares at gmail.com> wrote:

> I've been in the past told that mersenne-random was much better than
> the standard random package.

This is relative.  The Mersenne Twister algorithm has a large memory
footprint, but in relation to the size of the average Haskell program,
this is probably not much of an issue.

> So is it possible to use the fast and efficient mersenne generator
> with the convenient and general random API?

No, because mersenne-random provides an impure generator with a global
state, as is also pointed out by the Haddock documentation.  As an
alternative consider the mersenne-random-pure64 and the cprng-aes
packages.  Both provide the interface you want.

Personally I prefer the cprng-aes package, because it is reasonably fast
and convenient for non-cryptographic applications, but also provides a
strong Crypto-API interface, if you need cryptographically strong random


nightmare = unsafePerformIO (getWrongWife >>= sex)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20120209/9440a2e8/attachment.pgp>

More information about the Haskell-Cafe mailing list