[GHC] #12532: Remove sum and tuple names from knownKeyNames

GHC ghc-devs at haskell.org
Thu Aug 25 07:16:22 UTC 2016


#12532: Remove sum and tuple names from knownKeyNames
-------------------------------------+-------------------------------------
        Reporter:  bgamari           |                Owner:
            Type:  task              |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.0.1
      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 simonpj):

 I think the `IfaceTopBndr = Name` idea may be simpler than you think.

 In `BinIface.putName` we see two cases:
 {{{
 putName ... name
   | isKnownKeyName name
   = ...serialise the unique...
   | otherwise
   = ...go via the symbol table...
 }}}
 where `isKnownKeyName` knows how to parse the uniques for tuples etc.

 Very well then.  In "My approach", when fingerprinting an `IfaceDecl`,
 you are presumably going to have something like:
 {{{
 putIfaceTopBndr :: IfaceTopBndr -> M ()
 putIfaceTopBndr (IfaeKnownKeyName uniq)   = ...uniq...
 putIFaceTopBndr (IfaceTopNameOccName occ) = ...occ...
 }}}
 But instead of making the distiction with a data constructur, you can use
 `isKnownKeyName` just like `putName`!
 {{{
 putIfaceTopBndr :: IfaceTopBndr -> M ()
 putIFaceTopBndr name
   | isKnownKeyName name = ...(getUnique name)...
   | otherwise           = ...(getOccName name)...
 }}}
 Your proposed `IfaceTopBndr` lets you distinguish the known-key situation.
 But so does `isKnownKeyName`.  (Indeed we could use your `IfaceTopBndr`
 sum type at ''every'' occurrence of a name, i.e. for `IfaceExtName`.)

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12532#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list