
Hi Bardur,
You can just use the State monad to thread the StdGen around and "update" it when you need to. You can get a pure interface by hiding away the runState behind a function:
Thank you for your rapid response! Unfortunately, I didn't describe my problem accurately. This approach (or using MonadRandom) to pass around random generator with Monad, works fine when it's just enough to feed generator to the algorithm. But my situation is slightly different: random generator has to be passed around to implement the instance method for `Num`, so it can't take random generator as its argument. So I need some way to hide random generator from function type signatures. Fortunately, your response suggested me the alternative approach: converting the data-type into continuation-passing style. This should work fine when we just do some operations on data-type, but we have to feed the generator when we want to inspect its value, so it's not sufficient, though... -- Hiromi ISHII konn.jinro@gmail.com