[GHC] #11416: GHC mistakenly believes datatype with type synonym in its type can't be eta-reduced

GHC ghc-devs at haskell.org
Fri Jan 15 17:15:29 UTC 2016


#11416: GHC mistakenly believes datatype with type synonym in its type can't be
eta-reduced
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:
            Type:  bug               |               Status:  patch
        Priority:  normal            |            Milestone:
       Component:  Compiler (Type    |              Version:  8.1
  checker)                           |
      Resolution:                    |             Keywords:  TypeInType
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  GHC rejects       |  Unknown/Multiple
  valid program                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D1772
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by Ben Gamari <ben@…>):

 In [changeset:"165ae440b6bbf577eabf0b6d422ed6ea3bf949b4/ghc"
 165ae440/ghc]:
 {{{
 #!CommitTicketReference repository="ghc"
 revision="165ae440b6bbf577eabf0b6d422ed6ea3bf949b4"
 Expand type/kind synonyms in TyVars before deriving-related typechecking

 Before, it was possible to have a datatypes such as

 ```
 type ConstantT a b = a
 newtype T (f :: * -> *) (a :: ConstantT * f) = T (f a) deriving Functor

 data family TFam (f :: * -> *) (a :: *)
 newtype instance TFam f (ConstantT a f) = TFam (f a) deriving Functor
 ```

 fail to eta-reduce because either (1) a TyVar had a kind synonym that
 mentioned another TyVar, or (2) an instantiated type was itself a type
 synonym that mentioned another TyVar. A little bit of tweaking to
 `expandTypeSynonyms` and applying it before the eta-reduction check in
 the `deriving` machinery is sufficient to fix this.

 Fixes #11416.

 Test Plan: ./validate

 Reviewers: goldfire, simonpj, austin, bgamari

 Reviewed By: simonpj

 Subscribers: thomie

 Differential Revision: https://phabricator.haskell.org/D1772

 GHC Trac Issues: #11416
 }}}

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


More information about the ghc-tickets mailing list