Skip to content

shadowNames: Accept an OccName, not a GreName

Joachim Breitner requested to merge wip/joachim/simplify-shadowName into master

previously, the shadowNames function would take [GreName]. This has confused me for two reasons:

  • Why GreName and not Name? Does the difference between a normal name and a field name matter? The code of shadowNames shows that it does not, but really its better if the type signatures says so.

  • Why Name and not OccName? The point of shadowNames is to shadow unqualified names, at least in the two use cases I am aware of (names defined on the GHCI prompt or in TH splices).

    The code of shadowNames used to have cases that peek at the module of the given name and do something if that module appears in the GlobalRdrElt, but I think these cases are dead code, I don’t see how they could occur in the above use cases. Also, I replaced them with errors and GHC would still validate. Hence removing this code (yay!)

This change also allows shadowNames to accept an OccSet instead, which allows for a faster implemenation; I’ll try that separately. This in stead might help with !6703 (closed).

Edited by Joachim Breitner

Merge request reports