[Haskell-cafe] Re: [Haskell] Top Level <-
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?
> 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-220.127.116.11:Data.Unique.uniqSource" 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-18.104.22.168:Data.Unique.Unique 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".
More information about the Haskell-Cafe