[Haskell] Re: Global Variables and IO initializers

MR K P SCHUPKE k.schupke at imperial.ac.uk
Fri Nov 5 14:03:06 EST 2004

>You don't want stdin/stdout/stderr?

Also these are only available in the IO monad...

>without breaking referential transparency
>by use of unsafePerformIO hack.

I don't understand this still... how can it not break referntial transparancy.
For example consider if stdin were available outside the IO monad.

Could someone give an example of what these things are that need to be initialised
and that are safe.

The reason these things are unsafe is if I have two references to the same thing,
and one reference is used to mutate the thing, the other will see the mutated
value and not the original value as it should. The only solution has to be
these things must be constants or in the ST or IO monad.


More information about the Haskell mailing list