[Haskell] threading mutable state through callbacks

Adrian Hey ahey at iee.org
Tue Oct 12 18:25:04 EDT 2004


On Tuesday 12 Oct 2004 10:47 pm, Marcin 'Qrczak' Kowalczyk wrote:
> 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.

Yes of course, this is a well known problem with unsafePerformIO.
This is why in my earlier post I suggested that the use of special
syntax would also be a cue for the compiler to impose typing
restrictions.

Regards
--
Adrian Hey


More information about the Haskell mailing list