Skip to content
This repository was archived by the owner on Aug 3, 2024. It is now read-only.
This repository was archived by the owner on Aug 3, 2024. It is now read-only.

Intent to Refactor: Haddock.Interface.Create #586

Closed

Description

@ezyang

An important aspect of Haddock is interface creation (Haddock.Interface.Create); in particular, when we create an interface, we create a list of exports which correspond one-to-one with the documentation entries that Haddock eventually output on the page.

Haddock's current algorithm for computing the list of exports is closely tied to the renamed syntax we get from the module:

  • If there is no export list, we simply iterate through each renamed, top-level declarations, and create an export per declaration.

  • If there is an export list, we process each entry in the renamed export list, successively looking up the "name" in the list of renamed declarations, and then the external packages, until it is found.

There are two problems with this strategy.

  1. It duplicates smarts for figuring out what is "exported" with information that GHC has already computed during the renaming process. This logic duplication has lead to numerous bugs, where Haddock implements some resolution incorrectly:
  1. It doesn't work for Backpack signatures, where a signature may export entities which don't have renamed declarations in the local source file (they were inherited from external signatures.)

My plan is to refactor this code so that instead of recomputing "exports" from scratch, we instead directly use the mi_exports computed by GHC as the basis for what we are exporting. This should solve the module reexport bugs.

Hazards:

  1. I am assuming that mi_exports is sorted in the same way as the source-level exports. If it is not we'll have to do some logic to sort things correctly.

  2. Haddock avoids reproducing declarations for module reexports, if everything is reexported. That information is lost in mi_exports, so the obvious implementation strategy will result in us never generating module export items. I am FINE with this, I think NOT inlining the exports is a mistake. See also http://ghc.haskell.org/trac/ghc/ticket/10886 for a case where Haddock's default behavior is getting in our way. But maybe we can bring it back with some more cleverness.

Activity

  1. ezyang commented on Mar 13, 2017

    @ezyang
    ContributorAuthor

    Actually, this refactor doesn't work. because we need to pick up IEDoc and IEDocNamed from the export lists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions