[GHC] #11970: Simplify Parent for patten synonyms
GHC
ghc-devs at haskell.org
Fri Apr 22 16:35:47 UTC 2016
#11970: Simplify Parent for patten synonyms
-------------------------------------+-------------------------------------
Reporter: simonpj | Owner: mpickering
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.10.3
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by mpickering):
I have looked a bit at this. The problem from last time is that when
renaming exports we need to reject data constructors if they are exported
with a type constructor which is not their parent.
This is how the code was structured before my changes.
1. `tcg_rdr_env` is converted into a `kids_env` which is a map from
`NameEnv [GlobalRdrElt]`. The intention of this map that we can lookup a
type constructor and find which data constructors are allowed to be
bundled with it.
2. `lookupChildren` uses this map to check that all bundled constructors
are with the correct type constructor.
The problem which I ran into was that as we only have `GlobalRdrElt`s, at
this stage I couldn't see a way of telling whether a certain
`GlobalRdrElt` arose from a data constructor or a pattern synonym. It
seemed to me that the sole purpose of the `Parent` datatype was to
indicate when it should be allowed to export an identifier with a certain
type constructor (its parent). Because of this, I made the necessary
changes to `Parent` to indicate whether a `GRE` arose from a pattern
synonyn.
Do you see a better way of structuring this? Unless it is possible to
distinguish between a pattern synonym and a data constructor at this point
then it isn't safe to ignore an entry in the export list as it might be a
data constructor which we are not allowed to export with that type
constructor.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11970#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list