[GHC] #16194: deriving, wrong code: newtype T cat a = MkT ((forall xx. cat xx xx) -> a) deriving stock Functor

GHC ghc-devs at haskell.org
Wed Jan 16 15:38:50 UTC 2019


#16194: deriving, wrong code: newtype T cat a = MkT ((forall xx. cat xx xx) -> a)
deriving stock Functor
-------------------------------------+-------------------------------------
        Reporter:  Iceland_jack      |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.7
      Resolution:                    |             Keywords:  DeriveFunctor
                                     |  deriving RankNTypes
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 Iceland_jack):

 Fortunately `-XDerivingVia` handles it

 {{{
 > newtype T cat a = MkT ((forall xx. cat xx xx) -> a) deriving Functor via
 ((->) (forall xx. cat xx xx))

 ==================== Derived instances ====================
 Derived class instances:
   instance Functor (T cat) where
     fmap
       = coerce
           @((a -> b)
             -> ((forall (xx :: TYPE LiftedRep). cat xx xx) -> a)
                -> (forall (xx :: TYPE LiftedRep). cat xx xx) -> b)
           @((a -> b) -> T cat a -> T cat b)
           (fmap
              @((->) (forall (xx :: TYPE LiftedRep). cat xx xx) :: TYPE
 LiftedRep
                                                                   -> TYPE
 LiftedRep)) ::
           forall (a :: TYPE LiftedRep) (b :: TYPE LiftedRep).
           (a -> b) -> T cat a -> T cat b
     (<$)
       = coerce
           @(a
             -> ((forall (xx :: TYPE LiftedRep). cat xx xx) -> b)
                -> (forall (xx :: TYPE LiftedRep). cat xx xx) -> a)
           @(a -> T cat b -> T cat a)
           ((<$)
              @((->) (forall (xx :: TYPE LiftedRep). cat xx xx) :: TYPE
 LiftedRep
                                                                   -> TYPE
 LiftedRep)) ::
           forall (a :: TYPE LiftedRep) (b :: TYPE LiftedRep).
           a -> T cat b -> T cat a


 Derived type family instances:
 }}}

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


More information about the ghc-tickets mailing list