[GHC] #13398: Associated type family instance validity checking is too conservative

GHC ghc-devs at haskell.org
Tue Mar 14 15:31:35 UTC 2017


#13398: Associated type family instance validity checking is too conservative
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:  (none)
            Type:  bug               |               Status:  patch
        Priority:  high              |            Milestone:  8.2.1
       Component:  Compiler          |              Version:  8.1
      Resolution:                    |             Keywords:  TypeFamilies
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #11450            |  Differential Rev(s):  Phab:D3302
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by Ryan Scott <ryan.gl.scott@…>):

 In [changeset:"67345ccf51538acf2b6452c738ba641b119f5a5e/ghc" 67345cc/ghc]:
 {{{
 #!CommitTicketReference repository="ghc"
 revision="67345ccf51538acf2b6452c738ba641b119f5a5e"
 Allow associated types to pattern-match in non-class-bound variables

 Summary:
 After 8136a5cbfcd24647f897a2fae9fcbda0b1624035 (#11450), if you have
 a class with an associated type:

 ```
 class C a where
   type T a b
 ```

 And you try to create an instance of `C` like this:

 ```
 instance C Int where
   type T Int Char = Bool
 ```

 Then it is rejected, since you're trying to instantiate the variable ``b``
 with
 something other than a type variable. But this restriction proves quite
 onerous in practice, as it prevents you from doing things like this:

 ```
 class C a where
   type T a (b :: Identity c) :: c

 instance C Int where
   type T Int ('Identity x) = x
 ```

 You have to resort to an auxiliary type family in order to define this
 now,
 which becomes extremely tiring. This lifts this restriction and fixes
 #13398,
 in which it was discovered that adding this restriction broke code in the
 wild.

 Test Plan: ./validate

 Reviewers: simonpj, bgamari, austin

 Reviewed By: simonpj

 Subscribers: rwbarton, thomie

 Differential Revision: https://phabricator.haskell.org/D3302
 }}}

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


More information about the ghc-tickets mailing list