Skip to content
  • Ryan Scott's avatar
    Expand type/kind synonyms in TyVars before deriving-related typechecking · 165ae440
    Ryan Scott authored
    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
    165ae440