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

Pass to GHC visible modules for instance filtering #724

Merged
merged 2 commits into from
Jan 26, 2018

Conversation

harpocrates
Copy link
Collaborator

The GHC-side getNameToInstancesIndex filters out incorrectly some
instances because it is not aware of what modules are visible. On the
Haddock side, we need to pass in the modules we are processing.

On the GHC side, we need to check against those modules when checking
if an instance is visible.

Here is the GHC patch: https://phabricator.haskell.org/D4290

The GHC-side `getNameToInstancesIndex` filters out incorrectly some
instances because it is not aware of what modules are visible. On the
Haddock side, we need to pass in the modules we are processing.

On the GHC side, we need to check against _those_ modules when checking
if an instance is visible.
@alexbiehl
Copy link
Member

Very good catch Alec! Looking forward to this!

@harpocrates
Copy link
Collaborator Author

Me too! This sort of bug is the worst from a user perspective - you don't know that there are instances you aren't seeing, and once you do, you cease to trust Haddock.

Please do let me know if there is anything I should/could do to help this along - I understand the scheduling is a bit tight. I will endeavor to be responsive. 😃

Without a complete environment, we will miss some instances that were
encountered during typechecking.
@harpocrates
Copy link
Collaborator Author

Alright. I circled back and figured out why #469 (the Read instance of Array) was missing. The problem turned out to be only tangentially related to getNameToInstancesIndex.

We simply weren't updating the GlobalRdrEnv when processing modules, which meant that loadUnqualIfaces in getNameToInstancesIndex would load nothing (in fact, that was my clue: I noticed that it was loading stuff when I would use :info in GHCi, but it wasn't loading anything when called from Haddock).

The fix is just to update the environment every time we process a module. There are no extra GHC-side changes.

AFAICT, there are no more missing instances anywhere.

@alexbiehl
Copy link
Member

I will merge this as is, could you open another ghc diff updating the haddock submodule?

@harpocrates
Copy link
Collaborator Author

I'll open a new diff as soon as this is merged. (Anything wrong with just updating my existing diff: https://phabricator.haskell.org/D4290?)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants