`TH.reifyType` reports `StarT` instead of the actual kind synonym
Summary
When applied to a name of a type synonym, Language.Haskell.TH.reifyType
seems to always return Type
even if the intent is to define a kind definition.
Steps to reproduce
Note that the TypeConstructor
is treated as a synonym of kind Type -> Type
throughout the following short program. However the TH splice prints StarT
as its kind.
{-# Language KindSignatures, TemplateHaskell #-}
import Data.Kind (Type)
import Control.Monad.IO.Class (liftIO)
import qualified Language.Haskell.TH as TH
type TypeConstructor = Type -> Type
type Identity :: TypeConstructor
newtype Identity a = Identity {runIdentity :: a}
main = putStrLn (runIdentity $ Identity "Hello, World!")
$(TH.reifyType ''TypeConstructor >>= liftIO . print >> pure [])
The KindSignatures
extension is irrelevant, I've only added it to illustrate that everything works outside of TH. The output of the program is
$ runhaskell BugDemo.hs
StarT
Hello, World!
Expected behavior
$ runhaskell BugDemo.hs
AppT (AppT ArrowT StarT) StarT
Hello, World!
Environment
- GHC version used: 9.6.2
Optional:
- Operating System: Fedora Linux
- System Architecture: x86_64