[Haskell-cafe] random question

Daniel Fischer daniel.is.fischer at web.de
Wed Oct 7 17:51:23 EDT 2009

Am Mittwoch 07 Oktober 2009 23:28:59 schrieb Michael Mossey:
> Luke Palmer wrote:
> > On Wed, Oct 7, 2009 at 2:59 PM, Michael Mossey <mpm at alumni.caltech.edu> wrote:
> >> My thread about randomness got hijacked so I need to restate my
> >> remaining question here. Is it acceptable to write pure routines that
> >> use but do not return generators, and then call several of them from an
> >> IO monad with a generator obtained by several calls to newStdGen?
> >
> > It's gross.  What if you don't want IO as part of this computation?
> I don't quite follow your response. I want a program that initializes the
> generator from the global generator because I want different behavior every
> time I run it. So it will need IO. That's what I was trying to demonstrate.
> And I was wondering if one can get around the difficulty of passing the
> generator from call to call by using newStdGen in this way.
> Mike

Documentation says:

newStdGen :: IO StdGen
Applies split to the current global random generator, updates it with one of the results, 
and returns the other.

So it's as safe as split is.

More information about the Haskell-Cafe mailing list