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

Adrian Hey ahey at iee.org
Mon Nov 8 14:44:21 EST 2004

On Monday 08 Nov 2004 11:58 am, Peter Simons wrote:
> Adrian Hey writes:
>  > Perhaps you would like to show me your solution to the
>  > "oneShot" problem.
> I don't see any value in problems that are specifically
> designed so that they can be solved only with a global
> entity. 

Why not? Even if it was true that I had "specifically designed"
this problem, it's existance is of some interest I think.

> What is the real-world application for oneShot?

See my response to Keith.

>  > 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.
> Nobody said that. Use of unsafePerformIO does not equal bad
> code.

Nor did I accuse anyone of this. In this thread we're talking
one specific use of unsafePerformIO to create top level
"things with identity" (I think I'll call them TWI's from
now on).

This is what many in this thread assert is bad code, yourself
included it seems. Yet this is widely used in many programs and
libraries, even in ghc itself I believe. Not to mention stdin
etc.. (again).    

>  > But why would it be a problem if it was not?
> Because code like that is very hard to get right and very
> hard to maintain, and I don't want to use library code that
> uses this technique if I can avoid it.

This is dogma I think. There are many libraries you will need
to try to avoid using if this is really your position.

Adrian Hey

More information about the Haskell-Cafe mailing list