Exported modules in the GHC API

Hi, When encountering an IEModuleContents ModuleName export item, I'd like a simple way to get its original Module (with the original module name and package ID). It seems a bit complicated to have to go through the import items to figure this out. My question is: is there a simpler way, and if not, do you agree that the API should provide a simpler way? Thanks, David

On 22/05/2011 11:50, David Waern wrote:
Hi,
When encountering an IEModuleContents ModuleName export item, I'd like a simple way to get its original Module (with the original module name and package ID). It seems a bit complicated to have to go through the import items to figure this out. My question is: is there a simpler way, and if not, do you agree that the API should provide a simpler way?
This is the way it's defined in Haskell - a 'module' export expands to all those names in scope qualified with that module name. There might be several different modules imported with that name, and the 'module' export would export the contents of all of them. So I'm afraid you have to traverse the whole of the scope. I suspect we don't do this properly in Haddock, since the documentation always contains just a link to the exported module, right? Cheers, Simon

2011/5/23 Simon Marlow
This is the way it's defined in Haskell - a 'module' export expands to all those names in scope qualified with that module name. There might be several different modules imported with that name, and the 'module' export would export the contents of all of them. So I'm afraid you have to traverse the whole of the scope.
Aha. I suspected I didn't know the full story. Thanks for claring it up.
I suspect we don't do this properly in Haddock, since the documentation always contains just a link to the exported module, right?
Yes, it contains a link if the exported module is not hidden, otherwise we inline all the export items of the module. There are several things related to module exports that we do wrong currently. So I propose we should do this: There are two different behaviours: 1) We emit a link (under the original module name), if: * The module name is used to fully import exactly one non-hidden module. 2) We inline all imported export items from the module(s), if: * The module name is used by imports from more than one module or (one module): * The module name points to a hidden module * The module name points to a partially-imported module Sounds OK? That would fix #174 as well as handle multiple modules imported under the same name. David

On 23/05/2011 13:52, David Waern wrote:
2011/5/23 Simon Marlow
: This is the way it's defined in Haskell - a 'module' export expands to all those names in scope qualified with that module name. There might be several different modules imported with that name, and the 'module' export would export the contents of all of them. So I'm afraid you have to traverse the whole of the scope.
Aha. I suspected I didn't know the full story. Thanks for claring it up.
I suspect we don't do this properly in Haddock, since the documentation always contains just a link to the exported module, right?
Yes, it contains a link if the exported module is not hidden, otherwise we inline all the export items of the module. There are several things related to module exports that we do wrong currently.
So I propose we should do this:
There are two different behaviours:
1) We emit a link (under the original module name), if:
* The module name is used to fully import exactly one non-hidden module.
Fully *export*, you mean?
2) We inline all imported export items from the module(s), if:
(2) applies in all the cases that (1) doesn't, right? We can list those cases, but the code doesn't need to check for them explicitly, checking the condition for (1) is enough.
* The module name is used by imports from more than one module
or (one module):
* The module name points to a hidden module * The module name points to a partially-imported module
Sounds OK? That would fix #174 as well as handle multiple modules imported under the same name.
Great. Cheers, Simon

2011/5/27 Simon Marlow
On 23/05/2011 13:52, David Waern wrote:
2011/5/23 Simon Marlow
: This is the way it's defined in Haskell - a 'module' export expands to all those names in scope qualified with that module name. There might be several different modules imported with that name, and the 'module' export would export the contents of all of them. So I'm afraid you have to traverse the whole of the scope.
Aha. I suspected I didn't know the full story. Thanks for claring it up.
I suspect we don't do this properly in Haddock, since the documentation always contains just a link to the exported module, right?
Yes, it contains a link if the exported module is not hidden, otherwise we inline all the export items of the module. There are several things related to module exports that we do wrong currently.
So I propose we should do this:
There are two different behaviours:
1) We emit a link (under the original module name), if:
* The module name is used to fully import exactly one non-hidden module.
Fully *export*, you mean?
Yes, sorry.
2) We inline all imported export items from the module(s), if:
(2) applies in all the cases that (1) doesn't, right? We can list those cases, but the code doesn't need to check for them explicitly, checking the condition for (1) is enough.
Yep, exactly. I realized that after sending the mail. :-) David
participants (2)
-
David Waern
-
Simon Marlow