What are the recommended Haskell packages for pure pseudo-random generators (uniform Doubles)?
I’m interested in a convenient API in the first place, speed would be nice too.
Maybe mwc-random?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The standard System.Random has a pure interface. I would recommend wrapping it in a
State g(for whatever generator g you’re using) to avoid threading the state; thestatefunction makes turning functions likenextinto stateful actions easy:The MonadRandom package is based on the
State ginterface with pre-written wrappers for the generator functions; I think it’s fairly popular.Note that you can still run actions using this pure interface on the global RNG. MonadRandom has evalRandIO for the purpose.
I think you could write an (orphan) RandomGen instance to use mwc-random with these.