[Haskell] Re: Global Variables and IO initializers

Benjamin Franksen benjamin.franksen at bessy.de
Thu Nov 4 12:22:43 EST 2004


On Thursday 04 November 2004 17:20, Ben Rudiak-Gould wrote:
> Koen Claessen wrote:
>  >(1) Whenever a module uses an implicit parameter like that,
>  >it has to have a name that is different from all implicit
>  >parameters used by any other (future) module. (Yes, implicit
>  >paramers cannot be quantified by a module name.) This is
>  >difficult to ensure.
>
> This is one of the several ways in which the current implementation of
> implicit parameters is broken. Clearly they *should* belong to the
> module namespace, and if we modify the implementation so that they do,
> the problem you describe here goes away.

I have thought about this and I am not sure that this is possible or even 
makes sense. Remember that implicit parameters cannot be bound at the top 
level. They must be 'let' or 'where' bound. Indeed, when using them for a 
global variabe replacement, we do *not* want them at the top level, because 
we want to initialize them explicitly:

do_stuff_with_x = do
	use_it ?x -- refers to the x bound in main

main = do
	x <- initialize_x
	do_stuff_with_x

What if do_stuff_with_x is in another module? We could say that x belongs to 
namespace Main (i.e. the module in which it is bound)

do_stuff_with_x = do
	use_it ?Main.x

but then do_stuff_with_x cannot be called from any other module. This is bad. 
We could also say that x belongs to the namespace where x is used, but this 
would lead to similar problems, i.e. all usages of an implicit parm would be 
limited to one and only one module. This is bad too.

Ben (the other one)


More information about the Haskell mailing list