[Haskell-cafe] Re: [Haskell] Re: Global Variables and IO initializers

Adrian Hey ahey at iee.org
Mon Nov 8 03:05:59 EST 2004


On Monday 08 Nov 2004 6:00 am, Peter Simons wrote:
> Frankly, the idea that anyone would want to jump through
> hoops to add them to a purely functional language sounds
> bizarre to me. 

The first step to solving a problem is to at least recognise
that it exists. What is "bizarre" is that so many folk seem
to be in denial over this. Perhaps you would like to show
me your solution to the "oneShot" problem.

If this is such a wacky idea then why is the use of the
unsafePerformIO hack to do precisely this so common place?

I gather it's even used within ghc. If the two Simons
don't know how to write "proper" Haskell, what hope is
there for the rest of us.

Also a few more points that seem to need repeating..
1- We're talking about the general problem of creating
   top level "things with identity" (does anyone have
   a less cumbersome term?)
2- Creating top-level mutable variables (IORefs) is
   just one utterly trivial use of this capability.
3- Top-level does not imply global.
4- They already exist (stdin,stout,stderr) and I don't
   recall anybody ever complaining about this.
5- The above are already *implicitly* referenced by many
   other commonly used top level IO related functions.

> But by all means, as long as the compiler
> extension is disabled per default I won't mind. :-)

No doubt it would be, like all non-standard extensions.
But why would it be a problem if it was not?
If you don't want to use <- bindings then don't.
Nothing else has changed.

Regards
--
Adrian Hey



More information about the Haskell mailing list