| just to make certain i understand that double list:
|
| [GlobalRdrElt] : different things with the same unqualified name
| [ImportSpec] : different qualified names for the same thing
Nearly.
[GlobalRdrElt] : different things with the same *OccName*
The thing may note be in scope unqualified at all, but it'll
still be in the GlobalRdrEnv under its OccName
[ImportSpec] : various qualified names for the same thing
They may not differ. You can import M(T) as X and
import N(T) as X, so X.T is in scope "twice".
I tried to write it down on
http://hackage.haskell.org/trac/ghc/wiki/Commentary/Compiler/Renamer
Can you improve the wording there?
Simon
Here is how to understand these types:
The environment (GlobalRdrEnv) maps an OccName to a list of all entities with
that occurence name that are in scope (in any way).
Each of these is represented by a GlobalRdrElt, which gives the entity's Name
plus a specification of how it is in scope, its Provenance.
The Provenance has one of two forms. Either it is in scope because it is
defined in this module (LocalDef), or because it is imported. In the latter
case, the [ImportSpec] describes all the import statements that bring it into
scope.
An ImportSpec has two components:
An ImpDeclSpec that describes the entire import declaration. This is shared
between all entities brought into scope by a particular import declaration.
An ImpItemSpec that describes the import item that brought the entity into
scope.
So the [GlobalRdrElt] for a given
|
| in the context of ghci's :browse, it appears that unqualified names
| that would cause conflicts are simply not in scope (only their
| separate qualified forms are), so the [GlobalRdrElt] for a Name
| should always have length 1, correct?
|
|
| >The commentary is obviously deficient; could you spend a few
| >mins updating it so that you'd have been able to find this info
| >more easily?
|
| i wouldn't phrase it as harshly;-) it is more a matter of usage/
| perspective: if i had read the whole commentary recently, it
| would have occurred to me that this part answers my question.
| but i read it long ago, and didn't have a concrete application
| in mind, so i forgot most of it again. today, i have a concrete
| application in mind, but a commentary is no reference.
|
| so i don't think that adding to the main text alone would help
| people like me, who would need an index or a how-to faq.
| but trying to keep an entirely separate index or faq in sync
| with the main text seems hopeless as well.
|
| in light of this, my suggestion for improvement would be
| to embedd individual faq answers directly into the main
| text, with a special tag, and to have a separate faq page,
| which would do nothing but gather those tags from the
| main text in a single collection (preferably automatically).
|
| the entry i'd like to add (after the explanation of the
| GlobalRdrEnv types) would look somewhat like this
| (slightly generalised from my question, since your answer
| covers more ground):
|
| <faqentry id="importInfo">
| <question>
| How do I find import information for a Name in scope?
| </question>
| <answer>
| Use the GlobalRdrEnv (compiler/basicTypes/RdrName.lhs):
| * Get the OccName of the thing
| * Look that up in the GlobalRdrEnv, to get a [GlobalRdrElt]
| * Of these, at most one will have gre_name == the Name of the thing
| * Look at the gre_prov for that GRE
| The provenance tells you how it is in scope (perhaps in multiple ways).
| </answer>
| </faqentry>
|
| (or some non-XML format suitable for scripted extraction)
|
| this way, simply editing the main commentary text would
| also update an automatically generated how-to faq page
| (a bit like the way latex generates indices?). thus catering
| both for people who want to read the whole thing as a
| consistent text and for those who need to find information
| on how to achieve a specific task.
|
| i have a similar problem with the sources: i don't read all
| of them if i only want to make a small change to ghci, so
| i'm using InteractiveUI.hs and GHC.hs as my main entry
| points and reference index: if i know how what i want to
| do relates to something i know where to find, i can start
| from there, but sometimes, nothing similar exists, or the
| functionality is implicit or provided under a different name
| or in a different module (in this case, i should have thought
| of the ambiguous import errors as a starting point!-).
|
| claus
_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc