id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	os	architecture	failure	difficulty	testcase	blockedby	blocking	related
7022	Kind variable scoping problem in Iface file when using Template Haskell	goldfire		"Consider the following modules:

{{{
module PolykindTH where

import Language.Haskell.TH

makeSList :: Q [Dec]
makeSList = do
  a <- newName ""a""
  k <- newName ""k""
  return [TySynD (mkName ""SList"") [KindedTV a (AppT ListT (VarT k))]
                 (AppT (ConT (mkName ""Sing"")) (VarT a))]
-- makes ""type SList (a :: [k]) = Sing a""
}}}

{{{
{-# LANGUAGE PolyKinds, TypeFamilies, DataKinds, TemplateHaskell #-}

module Polykind where

import PolykindTH

data family Sing (a :: k)

$( makeSList )
}}}

When these modules are compiled, the resultant Iface file fails to load when code attempts to use the modules. To check this, I packaged this up with a cabal file, registered the package with my GHC (7.5.20120620), and then attempted to compile the following:

{{{
import Polykind

foo :: SList a -> Bool
foo = undefined
}}}

Here is the error:

{{{
Declaration for SList:
  Iface type variable out of scope:  k
Cannot continue after interface file error
}}}

I have attached a tarball of my cabal package for ease of testing."	bug	closed	normal	7.6.1	Compiler	7.5	fixed	TemplateHaskell PolyKinds		Unknown/Multiple	Unknown/Multiple	None/Unknown	Unknown	polykinds/T7022			
