Skip to content

Expected and actual kinds in "Couldn't match kind" error appear identical

Summary

When a "Couldn't match kind" error occurs because of a difference in the position of a forall., the expected and actual kinds printed will be identical and provide no indication of what the problem is.

Steps to reproduce

Try to compile this code:

import GHC.Exts (TYPE)

type Foo :: * -> forall r. TYPE r -> *
newtype Foo m a = MkFoo ()

type Bar = Foo :: forall r. * -> TYPE r -> *

You'll receive the following error:

error: [GHC-83865]
    • Expected kind ‘* -> * -> *’, but ‘Foo’ has kind ‘* -> * -> *’
    • In the type ‘Foo :: forall r. * -> TYPE r -> *’
      In the type declaration for ‘Bar’

Expected behavior

I expect the expected kind and actual kind printed in the error to be different, specifically to indicate the difference in where the forall. is.

Environment

  • GHC version used: Tested on both 9.8.2 and 9.10.0.20240313

Optional:

  • Operating System: Ubuntu 22.04
  • System Architecture: x86_64
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information