Heinrich Apfelmus wrote:
Lennart Augustsson wrote:
It's not often that one gets the chance to change something as
fundamental as the scoping rules of a language. Nevertheless, I would
like to propose a change to Haskell's scoping rules.
The change is quite simple. As it is, top level entities in a module
are in the same scope as all imported entities. I suggest that this
is changed to that the entities from the module are in an inner scope
and do not clash with imported identifiers.
Why? Consider the following snippet
module M where
import I
foo = True
I like it.
That said, how does the the fact that the scope is nested affect the
export list? If the module scope is inside the scope of the imports,
then this means the name I.foo should appear in the export list, not
foo , because the latter is in the outermost scope.
I think the solution to these problems is to rearrange the import
declarations so that the syntax mirrors the scoping rules. In other
words, I boldly propose to move the import declaration *before* the
module declaration, i.e.
import I
module M where
foo = True
or even
import I where
module M where
foo = True
This way, it is clear that the module M opens an inner scope and that
the export list of M uses the names from the inner scope.
Actually, the latter syntax should be
import I in ...
let import I in ...
The idea is that this mirrors a let expression. (The "where" keyword
would be misleading.)
Best regards,
Heinrich Apfelmus
--
http://apfelmus.nfshost.com
_______________________________________________
Haskell-prime mailing list
Haskell-prime@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-prime