[Haskell] Re: Global Variables and IO initializers

oleg at pobox.com oleg at pobox.com
Thu Nov 4 21:39:43 EST 2004

Jo'n Fairbairn wrote:
> The idea is simply that we should provide a mechanism of
> saying to a compiler "this file (of data) is a module that
> exports only the variable v". ...
> So we tell the compilation system that file
> /somewhere/contains-v contains the value of the variable
> v::String, and that it lives in the imaginary module
> Home.Of.V, and when the resulting programme is loaded, so is
> the content of /somewhere/contains-v, and v is bound to it.

That seems to be similar to the following:


In other words, we acknowledge the explicit phase separation and do the
initialization phase explicitly, and in Haskell. The advantage is that
the initialized variables look *exactly* as normal top-level variables
(and may be polymorphic). I believe Haskell plug-ins (reported at
Haskell Workshop 2004) is a far more advanced development and a
practical realization of the similar idea.

Incidentally, the above approach along with _many_ other approaches to
global variables are surveyed at

More information about the Haskell mailing list