Random

Mark Carroll mark@chaos.x-philes.com
Tue, 17 Dec 2002 10:04:37 -0500 (EST)


On 17 Dec 2002, Ketil Z. Malde wrote:

> Mark Carroll <mark@chaos.x-philes.com> writes:
(snip)
> > Can we still do this concisely and get the new state of the rng back out
> > the other end after the die has been thrown a few times?
>
> Oops; I missed that part!

No problem - it wasn't exactly clearly part of the original problem
specification. (-: It was good to see what randomRs does, too.

> > Or are things like newStdGen meant to be so cheap that it's fine to
> > use lots of different RNGs instead of one that you thread through
> > everything?

Also, I was wondering if I can or should use monads to thread the RNG
state through everything instead of always returning these two-tuples;
I've been peering at things like Control.Monad.Cont to try to see what
they're good for.

> I've no idea - I've always used StdGen's as if they were going out of
> style.  (You can, of course, `split` them and get two for the price of
> one)

Ah - I was never sure what to make of that - I normally just use the GHC
online Haddockised stuff which tells me no more than the type signatures,
but I suppose "split" must be more than (\x->(x,x))! (-: (I'll be happy to
help with adding documentation once I'm sure of the semantics myself.)

-- Mark