[Haskell-cafe] Re: [Haskell] Top Level <-

Ashley Yakeley ashley at semantic.org
Sun Aug 24 22:34:06 EDT 2008

Duncan Coutts wrote:
> This topic came up in #haskell this evening...
> On Sun, 2008-08-24 at 16:12 -0700, Ashley Yakeley wrote:
>> 1. Global mutable state. For instance, here's the count variable for 
>> Data.Unique rewritten:
>>    uniqSource :: MVar Integer
>>    uniqSource <- newMVarTL 0
>> Isn't that much nicer?
>> <http://haskell.org/haskellwiki/Top_level_mutable_state>
> It's nicer syntax but it's still not true. There's still no such thing
> as a global variable. There's always a scope.
> In this case what scope are we looking for? Process scope? Only one
> instance of uniqSource per process?

It is actually process scope, I believe. But it's one instance of 
"base-" per process: we don't care if 
there's also a "base-4.0:Data.Unique.uniqSource". The reason we don't 
care in this case is that base- and 
base-4.0:Data.Unique.Unique are different types, so they can't collide. 
These are different names in the same scope.

The scope I'm interested in is "Main.main" scope, i.e., the initialiser 
should be run no more than once per run of "main".

Ashley Yakeley

More information about the Haskell-Cafe mailing list