Skip to content

Template Haskell gets confused with scoped kind variables in a class declaration

When I say

{-# LANGUAGE TemplateHaskell, DataKinds, PolyKinds, TypeFamilies #-}

module Bug where

import Data.Proxy

$( [d|
  class kproxy ~ 'KProxy => C (kproxy :: KProxy a) where
    type TF (x :: a) :: Bool
  |])

I get

/Users/rae/temp/Bug.hs:7:4:
    Kind variable also used as type variable: ‘a_asJA’
    In the declaration for class C_asJy

/Users/rae/temp/Bug.hs:7:4:
    The exact Name ‘kproxy_asJB’ is not in scope
      Probable cause: you used a unique Template Haskell name (NameU), 
      perhaps via newName, but did not bind it
      If that's it, then -ddump-splices might be useful

The code in the TH quote compiles fine on its own.

Trac metadata
Trac field Value
Version 7.8.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Template Haskell
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