Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I use Data.Random.Source.IO to generate random numbers in Windows AND Unix? #9

Open
mcandre opened this issue Sep 13, 2012 · 1 comment

Comments

@mcandre
Copy link

mcandre commented Sep 13, 2012

I want my code to be platform-agnostic, but I can't find example code using Data.Random.Source.IO anywhere in the documentation.

@mokus0
Copy link
Collaborator

mokus0 commented Sep 27, 2012

Data.Random.Source.IO declares a "MonadRandom" instance for IO, which means that random variables can be sampled using the "sample" function.

For example:

sample (uniform 0 10) :: IO Int

Should "just work". If you need to reference it as a concrete "source", you can use the special value StdRandom, as in:

sampleFrom StdRandom (uniform 0 10) :: IO Int

StdRandom is a pseudo-source that refers to the default source of randomness for the monad in which it is used.

Sorry to take so long to reply. I've been mostly offline for a few months.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants