Skip to content

Kind checking fails when using PolyKinds

GHC HEAD and earlier versions are failing on the following program:

{-# LANGUAGE PolyKinds #-}
import GHC.Exts(Any)
f = (undefined :: a -> m a) :: Any -> Any Any
../tmp/test-polykinds.hs:3:6:
    Couldn't match kind ‘k1’ with ‘*’
      ‘k1’ is a rigid type variable bound by
           an expression type signature: Any -> Any Any
           at ../tmp/test-polykinds.hs:3:5
    Expected type: Any -> Any Any
      Actual type: Any -> m0 Any
    In the expression: (undefined :: a -> m a) :: Any -> Any Any
    In an equation for ‘f’:
        f = (undefined :: a -> m a) :: Any -> Any Any

Rewriting the program as follows has compilation succeed.

f = (undefined :: a -> m a) `asTypeOf` (undefined :: Any -> Any Any)

And removing the PolyKinds extension also has compilation succeed.

Trac metadata
Trac field Value
Version 7.8.2
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