
You can also use mutable variables (MVars) found in Control.Concurrent.MVar
http://haskell.org/ghc/docs/latest/html/libraries/base/Control-Concurrent-MV...
They might work depending on your implementation. The reading and
writing of MVars returns IO actions.
On 5/17/07, Dougal Stanton
On 17/05/07, Eric
wrote: H|i,
Does anyone know of a simple and straightforward way to use global variables in Haskell?
You can pass around an environment with the State or Reader monads (read/write and read-only respectively). If you want to do IO with the data you'll probably need the transformer equivalents: StateT or ReaderT.
I think there are some hackish ways of making IO variables but I don't know how that's done. I'd imagine it's frowned on from a stylistic point of view, too...
D. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Tom Harper Computer Science Major '07 Syracuse University +1 949 235 0185 Public Key: http://aftereternity.co.uk/rth.asc