[Haddock] [haddock] #145: Type class instances: link to source

haddock haddock at projects.haskell.org
Thu Oct 18 15:59:08 BST 2012


#145: Type class instances: link to source
----------------------------------+-----------------------------------------
Reporter:  MartijnVanSteenbergen  |        Owner:     
    Type:  enhancement            |       Status:  new
Priority:  major                  |    Milestone:     
 Version:  2.7.2                  |   Resolution:     
Keywords:                         |  
----------------------------------+-----------------------------------------
Changes (by byorgey):

 * cc: byorgey at cis.upenn.edu (added)


Comment:

 This came up again today on the libraries@ mailing list (and I would also
 love to see this feature), so I spent some time trying to figure out what
 would be necessary to implement this.  Here are my (quite sketchy) notes:

 {{{

      src/Haddock/Backends/Xhtml/Decl.hs:

        + ppDecl calls
          + ppDataDecl which calls
            + ppInstances which calls
              + Xhtml/Layout.hs:subInstances -- does actual generation
                of html for instances list.

        ppDataDecl gets a [DocInstance DocName];

        type DocInstance name = (InstHead name, Maybe (Doc name)) --
        from src/Haddock/Types.hs

        type InstHead name = ([HsType name], name, [HsType name])

        So already at this point we've forgotten source location
        information.  But if we had the information in the DocInstance
        type we could output it here.

        Tracing instances info backwards from ppDecl:

        + ppDecl is called from...
        + Haddock.Backends.Xhtml.processExport -- gets instance list from
          pattern-matching on (ExportDecl ...) :: ExportItem DocName.
        + called from ifaceToHtml, mapped over "exports", defined as
          exports = numberSectionHeadings (ifaceRnExportItems iface)

          ifaceRnExportItems is a record selector.

        + called from ppHtmlModule (iface passed along)
        + called from ppHtml, mapped over visible_ifaces, which is
          filtered from argument ifaces.

        + ppHtml called from Main.hs:render.  render gets ifaces as
          argument.

        + render called from renderStep, which passes on argument
          interfaces.
        + render called from main.  interfaces argument comes from call
          to readPackagesAndProcessModules.
        + readPackagesAndProcessModules gets ifaces from call to
          processModules.
        + processModules is in Haddock.Interface.

          This is the point at which I ran out of steam. But the hope
          is that somewhere in processModules or functions called by
          it, the actual source location information of instances is
          available.

          The DocInstance type would have to be modified to store
          source location info.
 }}}

-- 
Ticket URL: <http://trac.haskell.org/haddock/ticket/145#comment:4>
haddock <http://www.haskell.org/haddock>
Haddock, The Haskell Documentation Tool


More information about the Haddock mailing list