[Haskell] threading mutable state through callbacks

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Tue Oct 12 17:47:59 EDT 2004


Adrian Hey <ahey at iee.org> writes:

> The only real insanity with the current situation is the loss of
> referential transparency implied by the use of unsafePerformIO,
> which is why various pragma hacks and compiler switches need to be
> used (in order to prevent inappropriate substitutions). What I want
> to do is to make this or something similar "official", so the
> compiler really knows not to do this inappropriate subsitution in
> any event, even if the programmer forgot to use the necessary
> pragmas or compiler flags, or just didn't understand why they are
> needed.

It's not the only problem:
v = unsafePerformIO (newIORef undefined) :: IORef a
You can store an Integer there and try to take out a String.

-- 
   __("<         Marcin Kowalczyk
   \__/       qrczak at knm.org.pl
    ^^     http://qrnik.knm.org.pl/~qrczak/


More information about the Haskell mailing list