

There are also convenience functions randomRIO and randomIO that use and modify the standard generator in the IO monad. These are pure functions, and return a new generator so the user can use them in a manner appropriate to the context they are running in. random is similar, but elides the first argument, deriving it from the type being returned. The most basic function is randomR, which a tuple of a minimum and maximum value as a first argument, and the generator as a second, and returns a tuple of the first value from that generators sequence and a generator for the rest of the sequence. Generators can be passed to a variety of functions to perform operations on the random sequence they generate. If you don't care about where it starts, you can use getStdGen to get a RandomGen that was initialized with a random seed when the system was started. You can use mkStdGen to make one, giving it a starting point you've chosen. The fundamental type from System.Random is a RandomGen, a generator for a random sequence. There are sequences of numbers that are more less unpredictable, and if they are unpredictable enough, we call them random sequences. There is, of course, no such thing as a random number. We are currently looking into providing a faster module of equal or better quality that provides instances of the classes in System.Random. Second, System.Random has some performance issues. The Crypto.Random module provides an interface similar to System.Random as well as functions better suited to cryptography purposes for such a source. While System.Random provides a random sequence of reasonably high quality, it is not a source for cryptographic quality random bits.
RANDOM SEQUENCES GENERATOR SERIES
I'm going to follow that lead, and walk through a series of Monte Carlo method tests for problems with known solutions, so we can play with them and see how well they work. Monte Carlo method algorithms are particularly suited to this, and often used in introductory programming texts to introduce using random numbers in software. Many applications just need a sequence of random numbers, and the System.Random API makes that fairly simple. However, functional programming encourages the use of pure interfaces, rather than hiding the state. For instance, if you were using a hardware source of randomness, they would run in the IO monad since they were doing IO. Some applications require this style interface, so System.Random provides that, but requires running in an appropriate monad.

There may be type-specific variants, or an argument to indicate the return type, and probably some way set the sequence to a known state. In an imperative programming language, the random number generator API is typically a function or method that consumes and returns the next available element in the sequence.
