Global variables

Alastair David Reid
29 Nov 2001 10:33:04 -0700

> Hello, I am interested in using global variables (in GHC).  I need a
> variable to store list of Integers to store temporary results.  I
> have been reading the module MVar, but I wonder if there is an
> alternative way of doing it.  I have already implemented my function
> using an auxiliar argument where I put my lists of Integers.  Will
> the use of a global variable improve my function?

There's many ways to achieve the same goals as C programmers achieve
using mutable (global) variables including using laziness, use of
"accumulator" arguments, and, supported by most compilers but not
standard Haskell, mutable variables.  (Unlearning imperative
programming habits is one of the big challenges in learning Haskell.)

Since there are so many ways to avoid mutable variables and (many
less) circumstances where mutable variables are the best solution,
it's hard to give useful advice without more information about the

Alastair Reid