[GHC] #14440: Duplicate type family instances are permitted

GHC ghc-devs at haskell.org
Wed Nov 8 05:15:02 UTC 2017


#14440: Duplicate type family instances are permitted
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler (Type    |              Version:  8.2.1
  checker)                           |
      Resolution:                    |             Keywords:  TypeFamilies
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 AntC):

 Replying to [ticket:14440 RyanGlScott]:
 > Is this intended?

 I'm not sure if intended for identical type family instances, but it's
 certainly to be expected for partially overlapping type family instances.
 See examples in
 [https://downloads.haskell.org/~ghc/8.2.1/docs/html/users_guide/glasgow_exts.html
 #compatibility-and-apartness-of-type-family-equations User Guide].

 > My intuition screams "no", since if we offer //class// instance
 coherence, it seems like one ought to offer //type family// instance
 coherence as well.

 The trouble with ''class'' instances is that we can't infer whether the
 rhs method expressions are equivalent in case of overlapping instance
 heads. Thus you can't have class instances with identical heads -- GHC
 doesn't try checking if the rhs's are identical. Contrariwise type family
 rhs's have a very simple structure, needing only alpha-renaming to
 determine if confluent.

 > At the same time, I can't think of any threat to type soundness imposed
 by this.

 Quite. And that's the point in the papers that introduced type families
 circa 2008.

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


More information about the ghc-tickets mailing list