[Haskell-cafe] Re: Top Level <-

Ganesh Sittampalam ganesh at earth.li
Sun Sep 7 12:55:59 EDT 2008


On Sun, 7 Sep 2008, Brandon S. Allbery KF8NH wrote:

> You seem to think we must never insure that something will only be run 
> once, that any program that does require this is broken.  As such, the 
> standard Haskell libraries (including some whose interfaces are H98) are 
> unfixably broken and you'd better start looking elsewhere for your 
> "correct behavior".

Data.Unique might be unfixably broken, though perhaps some requirement 
that it not be unloaded while any values of type Unique are still around 
could solve the problem - though it's hard to see how this could be 
implemented sanely. But Data.Unique could (a) probably be replaced with 
something in terms of IORefs and (b) is pretty ugly anyway, since it 
forces you into IO.

I'm sure that for many other examples, re-initialisation would be fine. 
For example Data.HashTable just uses a global for instrumentation for 
performance tuning, which could happily be reset if it got unloaded and 
then reloaded. System.Random could get a new StdGen. I haven't yet had 
time to go through the entire list that Adrian Hey posted to understand 
why they are being used, though.

I'd also point out that if you unload and load libraries in C, global 
state will be lost and re-initialised.

Ganesh


More information about the Haskell-Cafe mailing list