Why does RandomIO need the unsafePerformIO hack? (was: [Haskell-cafe] Top-level state debate on the wiki)

Graham Klyne GK at ninebynine.org
Fri Dec 3 05:05:08 EST 2004

Looking at the wiki summary [1] (very good, BTW), I have a question  (I've 
skipped much of the debate, so please just give a message pointer if I 
missed something).

Why does RandomIO need to use the unsafePerformIO hack if its already in 
the IO monad?

BTW, if the goal is to have a random number generator as a pure (non-IO) 
function, I *do* think there's a reasonable semantic objection here.

I'd also like to request that some reference links are added for some of 
the proposed solutions:
   2b - reference to stToIO
   3 - reference  to Data.Dynamic, and how a dictionary of types can be 
used to provide global variables.


[1] http://haskell.org/hawiki/GlobalMutableState

Graham Klyne
For email:

More information about the Haskell-Cafe mailing list