[Haddock] Fwd: Fully qualified identifiers

Tobias Brandt tob.brandt at googlemail.com
Fri Aug 27 03:27:25 EDT 2010


On 27 August 2010 09:11, Isaac Dupree <ml at isaac.cedarswampstudios.org> wrote:
> If you can't get it out of a GHC Name, it will be tricky to find the
> information by the time that we are converting Name to DocName. -- i.e.
> the information may only be available in/before the GHC-renamer pass
> that turns RdrNames into Names, called from Haddock.Interface.Rn module.
>  Note that Haddock-renaming from Name to DocName is different, and has
> to come noticably later in the process (Haddock haddocks a group of
> modules in one go, and Haddock-renaming comes after all individual
> modules have each been processed, Haddock.Interface.Create, including
> GHC-renaming). ghc:RdrName.nameRdrName is *not* what you want (check its
> source) (also checking ghc:Name.Name source makes it look that Names
> have completely forgotten that information...)  You could try
> introducing an intermediate type between Name and DocName that you
> produce in Haddock.Interface.Rn (it should be easy, the monad is only Id
> and all the code does is a few lookups in an unchanging environment);
> changing that name-type might be messy in other parts of the code, or
> not (try GHC.getName, and make sure your intermediate type is an
> instance of GHC.NamedThing)

I first wanted to add "local" qualification, i.e. only imported names
are fully qualified (maybe with an exception for the Prelude). That
would be pretty easy to implement as the module name is known in
Haddock.Backends.Xhtml.ppHtmlModule and could just be tagged onto the
Qualification flag.
Another possibility would be to use "relative" qualification, i.e. a
name A.B.x imported into module A would be qualified as B.x. This is
technically
still ambiguous as there could be a top-level module B, but in most cases
this would be a good compromise.

Both of them are way easer to implement than original qualification, so
I'll try them first.



More information about the Haddock mailing list