Comparing instance heads
david.waern at gmail.com
Sun Nov 15 14:58:47 EST 2009
My little sunday afternoon project consists of implementing comments
on instances in Haddock, but now I'm stuck.
Here's the problem:
Haddock associates an instance declaration with a comment using their
respective SrcLocs. So this association has to be done using the
instance declarations from the renamed syntax, because that seems like
the last point where the SrcLocs of instances are retained (correct me
if I'm wrong). This results in a map from instance heads to
documentation. The map contains all instances that is defined in the
module being processed.
Later, Haddock uses the .hi files to get all instances belonging to a
certain export item, using getAllInfo. Note that these are all
instances known by GHC, so they may not only come from the package
being processed. These are the instances shown in the documentation.
For each such instance, I'd like to look up its documentation in the
previously mentioned map. However, since there is no Id/Name for the
instances in the map, this lookup has to be done based on the instance
How do you suggest I do the comparison of instance heads? Is there
something in GHC that can be used? Should the GHC API just provide
Eq/Ord for HsType?
More information about the Cvs-ghc