RE: More feedback on Haskell 98 modules from the Programatica Team
| However, I think there is a risk that name clashes may be | introduced. If module A defines and exports f, and imports | (qualified) and exports module B, which also defines f, then | a module C that imports A has two fs, both of which have the | qualified name A.f in C, even though there is no conflict in | A. This suggests that only unqualified imports should be | exported in a "module X" export list entry. The Report already covers this point (though I don't have it to hand). There must be no name clashes among the *unqualified* names of the exported things; so in your example, module A's export list is illegal. Simon
Simon Peyton-Jones wrote:
| However, I think there is a risk that name clashes may be | introduced. If module A defines and exports f, and imports | (qualified) and exports module B, which also defines f, then | a module C that imports A has two fs, both of which have the | qualified name A.f in C, even though there is no conflict in | A. This suggests that only unqualified imports should be | exported in a "module X" export list entry.
The Report already covers this point (though I don't have it to hand). There must be no name clashes among the *unqualified* names of the exported things; so in your example, module A's export list is illegal.
I'm not sure about this. The report says (about export lists): 5.The set of all entities brought into scope from a module m by one or more unqualified import declarations may be named by the form `module m', which is equivalent to listing all of the entities imported from the module. My example was: module A (f, module B) where import B (g) import qualified B (f) f = ... At present, this is legal, and a module C, which imports A, sees f (defined in A) and g (imported from B). B's f is imported for local use in A, is qualified to avoid a name clash in A, and is not exported by A. You are proposing to drop the word "unqualified" from the rule, which would result in the addition of B's f to A's export list, creating a name clash there. As you say, this is detected as an error in A. My point was that there is no error with the present wording of the report. Qualified import is a mechanism for avoiding name clashes, but export of qualified names changes the module part of the name, with the risk of creating a name clash. This is an argument for keeping the requirement that export of qualified names is explicit, so that the programmer can check the validity of each one as it is written, and not allowing bulk export of all imported qualified names through a "module X" export list item. --brian
participants (2)
-
Brian Boutel -
Simon Peyton-Jones