Skip to content

Misleading "Kind mis-match on LHS of default declaration" error

This program fails to typecheck, unsurprisingly:

{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Bug where

class C a where
  type T a :: k
  type T a = Int

But the error message it gives threw me for a loop initially:

$ /opt/ghc/8.2.1/bin/ghci Bug.hs
GHCi, version 8.2.0.20170704: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/rgscott/.ghci
[1 of 1] Compiling Bug              ( Bug.hs, interpreted )

Bug.hs:7:3: error:
    • Kind mis-match on LHS of default declaration for ‘T’
    • In the default type instance declaration for ‘T’
      In the class declaration for ‘C’
  |
7 |   type T a = Int
  |   ^^^^^^^^^^^^^^
Failed, 0 modules loaded.

The LHS of the default declaration is perfectly fine - the real source of the error is the RHS!

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