

Lennart Augustsson lennart at augustsson.net
Mon Nov 8 07:14:57 EST 2004

Adrian Hey wrote:

> Why are top level IORefs any worse than other IORefs (for
> example)?

Because global variables are just BAD.  They have been considered
bad a long time, it's not a Haskell thing.

If you really grok the functional way of doing things there should
be *very*, *very* few times you need a global variable.
I incredibly suspicious about code that "needs" it.  Having a global
variable almost always you have a single copy of some data structure;
there is no way to create two of them.  I claim that the right way
is to have a handle to your "object" and pass that around.  (But I
can also be persuaded that there might be exceptions.  (I've written
a few lines of Haskell and I have used a global variable once, I

	-- Lennart

More information about the Haskell-Cafe mailing list