RNG within an IORef for convenient concurrent use https://bitbucket.org/soostone/rng-utils

Version on this page:0.2.1
LTS Haskell 12.1:0.3.0
Stackage Nightly 2018-07-20:0.3.0
Latest on Hackage:0.3.0

See all snapshots rng-utils appears in

BSD3 licensed by Ozgun Ataman, Snap Framework Authors
Maintained by ozgun.ataman@soostone.com

Module documentation for 0.2.1


This simple utility wraps an IORef around random for the common use case of initializing an RNG once and using it in various places within an IO context. The haddocks should otherwise be self explanatory.

Any comments, improvement opportunities, feedback most welcome.

Upgrade Notes

In version 0.3.0, rng-utils switched from targeting mwc-random to random. random sees more use in the Haskell ecosystem, has fewer dependencies and the performance difference was negligible in comparison to the concurrency mechanism. If you feel strongly that mwc-random should be part of the library, let us know in an issue and we can look into supporting multiple backends.



  • Switch to IORef instead of MVar. This should provide better performance under high contention.
  • Swap out internal RNG for System.Random. It turns out that the gains to be had by using mwc-random are outshadowed by the mutation inherent to this library, so it is preferable to leverage System.Random which appears to be more commonly used and has better coverage of types to generate.
  • Add rngRIO and rngIO convenience functions for generating values.
Depends on 3 packages:
Used by 1 package:
comments powered byDisqus