[Haskell-cafe] Current situation regarding global IORefs

Brian Hulley brianh at metamilk.com
Thu Apr 27 16:53:35 EDT 2006


John Meacham wrote:
> On Thu, Apr 27, 2006 at 11:09:58AM +0100, Adrian Hey wrote:
>> What really frustrates me about all this is that AFAIK there are no
>> significant technical or theoretical reasons why we can't get
>> this safety (without resort to the unsafePerformIO hack). The
>> only serious obstacle seems political, with this very strange but
>> apparently widespread dogma about so called "global variables"
>> being inherently evil, regardless of the circumstances or purpose
>> for which they are used.
>
> indeed. perhaps we just need to come up with a more functional name
> than 'global variables'. like 'universal monad' or 'world
> transformer', maybe 'augmented IO'. :)

I like "augmented IO", because this makes it clear that there is absolutely 
no difference between the existing IO monad which keeps track of global 
RealWorld state, and an augmented IO monad which keeps track of RealWorld + 
state of IORefs needed internally by different components of a software 
system.

At the moment, there is a strange unnatural discrepancy between the fixed 
set of built-in privileged operations such as newUnique which are "allowed" 
to make use of global state and user defined operations which have to rely 
on a shaky hack in order to preserve natural abstraction barriers between 
components such as a user-defined Unique, Atom, and anything involving 
memoisation or device management etc.

Regards, Brian. 



More information about the Haskell-Cafe mailing list