[GHC] #13272: DeriveAnyClass regression involving a rigid type variable

GHC ghc-devs at haskell.org
Sat Feb 11 22:32:25 UTC 2017


#13272: DeriveAnyClass regression involving a rigid type variable
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.2.1
       Component:  Compiler (Type    |              Version:  8.1
  checker)                           |
      Resolution:                    |             Keywords:  Generics
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  GHC rejects       |  Unknown/Multiple
  valid program                      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by RyanGlScott):

 And it gets worse if you make a slight tweak to the original program by
 introducing an intermediary type variable:

 {{{#!hs
 {-# LANGUAGE DefaultSignatures #-}
 {-# LANGUAGE DeriveAnyClass #-}
 {-# LANGUAGE DeriveGeneric #-}
 {-# LANGUAGE FlexibleContexts #-}
 {-# LANGUAGE ScopedTypeVariables #-}
 {-# LANGUAGE TypeFamilies #-}
 module TypeName where

 import GHC.Generics

 class TypeName a where
   typeName         :: proxy a -> String
   default typeName :: (Generic a, Rep a ~ gg, gg ~ D1 d f, Datatype d)
                    => proxy a -> String
   typeName _ = gtypeName $ from (undefined :: a)

 gtypeName :: Datatype d => D1 d f p -> String
 gtypeName = datatypeName

 data T a = MkT a
   deriving (Generic, TypeName)
 }}}

 Then it sends the compiler (presumably the constraint solver) into an
 infinite loop! I'll attach the portion of `-ddump-tc-trace`'s output that
 appears to be looping.

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


More information about the ghc-tickets mailing list