[Haskell-cafe] Re: [Haskell] Top Level <-
ashley at semantic.org
Sun Aug 31 17:36:05 EDT 2008
Ganesh Sittampalam wrote:
> On Sat, 30 Aug 2008, Ashley Yakeley wrote:
>> OK. Let's call it "top-level scope". Haskell naturally defines such a
>> thing, regardless of processes and processors. Each top-level <- would
>> run at most once in top-level scope.
>> If you had two Haskell runtimes call by C code, each would have its
>> own memory allocator and GC; IORefs, Uniques and thunks cannot be
>> shared between them; and each would have its own top-level scope, even
>> though they're in the same process.
> That sounds more feasible - though it does constrain a plugin
> architecture (in which Haskell code can dynamically load other Haskell
> code) to cooperate with the loading RTS and not load multiple copies of
> modules; this might make linking tricky.
This is a good idea anyway. It's up to the dynamic loading architecture
to get this right.
> There's also the problem Duncan
> Coutts mentioned about loading multiple versions of the same module -
> what are the semantics of <- in relation to that?
If they are different versions, they ought to be considered different
modules with different names. Thus, Unique in base-126.96.36.199 ought to be a
different type than Unique in base-4.0. Thus any top-level initialisers
ought to be considered different and be run separately.
What's the current static behaviour? What happens if I link with
packages B & C, which link with different versions of A?
> Also, it's no use for mediating access to a resource or library that can
> only be accessed once, right? In fact, even without the problem of two
> Haskell runtimes in one process this can't work, since some library in
> another language might also choose to access that resource or library.
> What applications does this leave beyond Data.Unique and Random?
So far we've just looked at declaring top-level IORefs and MVars.
By declaring top-level values of type IOWitness, you can generate open
witnesses to any type, and thus solve the expression problem. See my
open witness library and paper:
More information about the Haskell-Cafe