[GHC] #13151: Make all never-exported IfaceDecls implicit

GHC ghc-devs at haskell.org
Thu Jan 19 00:58:45 UTC 2017


#13151: Make all never-exported IfaceDecls implicit
-------------------------------------+-------------------------------------
           Reporter:  ezyang         |             Owner:  ezyang
               Type:  task           |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.1
  (Type checker)                     |
           Keywords:  backpack       |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Consider the representation of an instance in an interface file. It is
 always associated with a DFun, but the DFun is stored as a separate
 IfaceDecl.

 You might wonder if it's possible for an IfaceClsInst to refer to an
 externally defined DFun, or if it's possible to have a DFun but no
 IfaceClsInst associated with it. The current ClsInst representation won't
 tell you, but in fact, it's impossible. For example, DFuns are manually
 added to the type environment by TidyPgm, which literally goes through the
 list of ClsInsts to pull out the set of DFunIds which need to be added to
 the TypeEnv.

 This all seems horribly indirect. Why not just *embed* the IfaceDecl
 describing the DFun inside IfaceClsInst, and treat the DFun as an
 "implicit TyThing"? This makes it clear that the instance declaration
 canonically defines the DFun.

 To do this, we have to expand our idea of implicit TyThings; at the
 moment, only a TyThing can be associated with implicit TyThings. With this
 change, instances and family instances can also be associated with
 implicit TyThings. But this doesn't seem like too much.

 Why does this matter? I was cleaning up some code in Backpack, and I
 noticed that I had written some very complicated things to handle DFuns
 and coercion axioms, because they were indirected through a Name, even
 though morally they should have been "implicit"-like things. The proposed
 refactor here would solve this correctness problem.

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


More information about the ghc-tickets mailing list