Skip to content

Very unhelpful message resulting from kind mismatch

The following code:

module Foo where

import Data.Typeable

tyConOf :: Typeable a => Proxy a -> TyCon
tyConOf = typeRepTyCon . typeRep

tcList :: TyCon
tcList = tyConOf (Proxy :: Proxy [])

fails because -XPolyKinds is not enabled. But the error message that you get is quite different on GHC 7.10 and 8.0.

On GHC 7.10.3:

[1 of 1] Compiling Foo              ( Foo.hs, Foo.o )

Foo.hs:9:19:
    Couldn't match kind ‘* -> *’ with ‘*’
    Expected type: Proxy a0
      Actual type: Proxy []
    In the first argument of ‘tyConOf’, namely ‘(Proxy :: Proxy [])’
    In the expression: tyConOf (Proxy :: Proxy [])
    In an equation for ‘tcList’: tcList = tyConOf (Proxy :: Proxy [])

But on GHC 8.0.1-rc1:

Foo.hs:9:19: error:                                                                                       
    • Expected kind ‘Proxy []’,                                                                           
        but ‘Data.Proxy.Proxy :: Proxy []’ has kind ‘Proxy []’                                            
    • In the first argument of ‘tyConOf’, namely ‘(Proxy :: Proxy [])’                                    
      In the expression: tyConOf (Proxy :: Proxy [])
      In an equation for ‘tcList’: tcList = tyConOf (Proxy :: Proxy [])
Trac metadata
Trac field Value
Version 8.0.1-rc1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Type checker)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information