Skip to content

Can't write instances of higher-rank kinded variables

{-# language PolyKinds             #-}
{-# language QuantifiedConstraints #-}
{-# language RankNTypes            #-}

import Data.Kind (Type)

class    C (co :: forall k. k -> Type)
instance C (co :: forall k. k -> Type)

gives

$ ./ghc-stage2 --interactive -ignore-dot-ghci 1260_bug.hs
GHCi, version 8.7.20190211: https://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Main             ( 1260_bug.hs, interpreted )

1260_bug.hs:8:13: error:
    • Expected kind ‘forall k. k -> *’, but ‘co’ has kind ‘k0’
    • In the first argument of ‘C’, namely
        ‘(co :: forall k. k -> Type)’
      In the instance declaration for ‘C (co :: forall k. k -> Type)’
  |
8 | instance C (co :: forall k. k -> Type)
  |             ^^
Failed, no modules loaded.
Prelude>

Only the instance part causes trouble, should this work or not?

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