TH-reified types can suffer from kind signature oversaturation
I ran into this issue when attempting to fix #11785 (closed) in TcSplice
. Here's a simple Template Haskell program:
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TemplateHaskell #-}
module Bug where
import Data.Proxy
import Language.Haskell.TH
newtype Foo = Foo (Proxy '[False, True, False])
$(return [])
main :: IO ()
main = putStrLn $(reify ''Foo >>= stringE . pprint)
The output of this program is unfortunately noisy:
$ runghc Bug.hs
newtype Bug.Foo
= Bug.Foo (Data.Proxy.Proxy ((':) 'GHC.Types.False
((':) 'GHC.Types.True
((':) 'GHC.Types.False
('[] :: [GHC.Types.Bool]) :: [GHC.Types.Bool]) :: [GHC.Types.Bool]) :: [GHC.Types.Bool]))
Somehow, we've ended up with four copies of a [GHC.Types.Bool]
kind annotation! It definitely feels like Template Haskell could be more conservative here in choosing which types get explicit kind annotations - at the most, I'd only expect '[]
to get one.
Trac metadata
Trac field | Value |
---|---|
Version | 8.2.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Template Haskell |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |