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

Adrian Hey ahey at iee.org
Thu Aug 28 05:00:50 EDT 2008


Lennart Augustsson wrote:
 > I don't don't think global variables should be banned, I just think
 > they should be severly discouraged.

If you're saying a language should not provide a sound way to do
this (as I believe you are), then AFAICT for all practical purposes
you *are* saying you think global variables should be banned.

Where are we going to be if the unsafePerformIO hack ever becomes
*really* unsafe?

and..

> I'm certain you can write a kernel in Haskell where the only use of
> global variables is those that hardware interfacing forces you to use.

But what you haven't explained is why this is even desirable? I don't
doubt it's true in an academic sense if you don't mind sacrificing
safety and modularity. Why wasn't this done in the (presumably) much
simpler case of the Haskell base libs? No hardware constraints there.

There are plenty situations where it makes no semantic sense to allow
2 or more or some "thing". A list of all active processes for example.

Why would I ever want 2 or more lists of all active processes? I think
I'd just be setting myself up for trouble and heartache by even allowing
such a possibility.

Now I could get the safety I need by wrapping all this stuff up in my
own custom augmented IO monad right at the start of main. But this
solution still lacks modularity. The top level <- bindings are just
a modular and extensible way to achieve the same thing AFAICS
(augmenting "real world" state with my own custom state).

Regards
--
Adrian Hey


More information about the Haskell-Cafe mailing list