Skip to content

Kind generalisation without -XPolyKinds leading to breakage

The following program is reduced from libraries/Cabal/Cabal/src/Distribution/Utils/Path.hs, which I didn't manage to compile with @bgamari's build-cabal.sh script today:

{-# LANGUAGE DeriveDataTypeable #-}

module Path where

import Data.Typeable

class Typeable a => C a where
data T a = T deriving Typeable
instance Typeable a => C (T a)

If compiled with HEAD (and -fprint-explicit-kinds, this errors

Path.hs:9:10: error:
    • Could not deduce (Typeable @(*) k)
        arising from the superclasses of an instance declaration
      from the context: Typeable @k a
        bound by the instance declaration at Path.hs:9:10-30
    • In the instance declaration for ‘C @{*} (T @{k} a)’
  |
9 | instance Typeable a => C (T a)
  |          ^^^^^^^^^^^^^^^^^^^^^

Apparently, T's type parameter has been kind generalised. Why? I don't think -XDeriveDataTypeable implies -XPolyKinds. Yet the error message mentions an implicit kind k that appears nowhere else in the program.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information