[Haskell] Re: Global Variables and IO initializers

Benjamin Franksen benjamin.franksen at bessy.de
Fri Nov 5 12:00:58 EST 2004


On Friday 05 November 2004 15:45, MR K P SCHUPKE wrote:
> >The point is to avoid threading global state to IO actions manually.
> >Programming langages exist in order to conveniently write programs in,
> >not only to admire their beauty.
>
> So if you are not interested in beauty, why not use the IO monad! If
> something is IO then declare it. You should not lie to the type system,
> or try to cheat it. It is your friend, and will help prevent errors
> in code.

Just to clarify (and not to take position): in order to access a global 
variable in the unsafePerformIO-newIORef-style you still need to be in the IO 
Monad.

Eiffel can dispense with global variables not least because objects contain 
mutable state. And the methods cann access this state inside their object 
without taking it as an argument.

Ben


More information about the Haskell mailing list