[GHC] #15412: "Instance head is not headed by a class" when `Constraint` replaced with `type C = Constraint`

GHC ghc-devs at haskell.org
Wed Jul 18 07:23:27 UTC 2018


#15412: "Instance head is not headed by a class" when `Constraint` replaced with
`type C = Constraint`
-------------------------------------+-------------------------------------
           Reporter:  Iceland_jack   |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:  8.6.1
          Component:  Compiler       |           Version:  8.4.3
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 {{{#!hs
 {-# Language DataKinds, TypeInType, TypeFamilies #-}

 import Data.Kind

 newtype I a = I a

 type C = Constraint

 type family
   UnitC :: Constraint where
   UnitC = ()

 instance UnitC => Functor I where
   fmap = undefined
 }}}

 this works fine, but if I try to use the constraint synonym `C` (`UnitC ::
 C where`) fails with "Instance head is not headed by a class" which has
 '''no''' Google hits outside of the
 [https://hackage.haskell.org/package/ghc-8.4.1/docs/src/TcValidity.html#checkValidInstance
 compiler]

 {{{
 $ ghci -ignore-dot-ghci hs/249.hs
 GHCi, version 8.5.20180128: http://www.haskell.org/ghc/  :? for help
 [1 of 1] Compiling Main             ( hs/249.hs, interpreted )

 hs/249.hs:13:10: error:
     • Instance head is not headed by a class
     • In the instance declaration for ‘Functor I’
    |
 13 | instance UnitC => Functor I where
    |          ^^^^^^^^^^^^^^^^^^
 Failed, no modules loaded.
 Prelude>
 }}}

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


More information about the ghc-tickets mailing list