Skip to content

Reification drops necessary kind annotations

Consider the following:

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

import Language.Haskell.TH

type family Poly (a :: k) :: *
type instance Poly (x :: Bool) = Int
type instance Poly (x :: Maybe k) = Double

$( do info <- reify ''Poly
      runIO $ putStrLn $ pprint info
      return [] )

Compiling with HEAD yields this output:

type family Main.Poly (a_0 :: k_1) :: *
type instance Main.Poly x_2 = GHC.Types.Double
type instance Main.Poly x_3 = GHC.Types.Int

The problem is that the type patterns in the reified instances are just plain variables, without their kind annotations. This omission makes the instance declarations unfaithful to the original meaning.

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