[Haskell-cafe] Re: [Haskell] Top Level <-

Adrian Hey ahey at iee.org
Tue Sep 2 03:15:04 EDT 2008

Ganesh Sittampalam wrote:
> You see this as a requirement that can be discharged by adding the ACIO 
> concept; I see it as a requirement that should be communicated in the type.
> Another way of looking at it is that Data.Unique has associated with it 
> some context in which Unique values are safely comparable. You want that 
> context to always be the top-level/RTS scope, I would like the defining 
> that context to be part of the API.

But why pick on Data.Unique as special? Because I just happened to have
pointed out it uses a "global variable"? If you didn't know this I
suspect this issue just wouldn't be an issue at all. Why haven't you
raised a ticket complaining about it's API having the "wrong" type
sigs? :-)

There's shed loads of information and semantic subtleties about pretty
much any operation you care to think of in the IO monad that isn't
communicated by it's type. All you know for sure is that it's weird,
because if it wasn't it wouldn't be in the IO monad.

So I think you're applying double standards.

>> We have to have something concrete to discuss and this is the simplest.
>> Like I said there are a dozen or so other examples in the base package
>> last time I counted
> Would you mind listing them? It might help provide some clarity to the 
> discussion.

Here's what you can't find in the libs distributed with ghc. Note this
does not include all uses of unsafePerformIO. It only includes uses
to make a "global variable".

Control.Concurrent           1
Control.OldException         1
Data.HashTable               1
Data.Typeable                1
Data.Unique                  1
GHC.Conc                     8
GHC.Handle                   3
System.Random                1
Language.Haskell.Syntax      1
System.Posix.Signals         2
System.Win32.Types           1
Network.BSD                  1
System.Posix.User            1
Total:                      23

In the ghc source you can find 16 uses of the GLOBAL_VAR macro (can't
imagine what that does :-).

I didn't even attempt to figure out how global variables might be the
rts source. Anyone care to hazard a guess?

You can find a few more in the extra libs..
Graphics.UI.GLUT.Menu                        1
Graphics.UI.GLUT.Callbacks.Registration      3
Graphics.Rendering.OpenGL.GLU.ErrorsInternal 1
Total:                                       5

A few more:
wxHaskell 6
c2hs      1
GTK2HS    1
SDL       0 !!

However, I happen to know that SDL suffers from the initialisation
issue and IIRC it needs at least 1 global to stop user using an unsafe
(possibly segfault inducing) calling sequence.

Anyway, that's all from me because I'm bored with this thread now.

Adrian hey

More information about the Haskell-Cafe mailing list