-ddump-splices omits required parentheses when printing explicit kind signature
If you run this program with GHC 9.4.4 or later:
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -ddump-splices #-}
module Bug where
import Data.Kind
$([d| f :: (Bool :: Type)
f = True |])
You'll get this output:
$ ghc-9.4.4 Bug.hs -dsuppress-uniques -fforce-recomp
[1 of 1] Compiling Bug ( Bug.hs, Bug.o, Bug.dyn_o )
Bug.hs:(8,2)-(9,18): Splicing declarations
[d| f :: (Bool :: Type)
f = True |]
======>
f :: Bool :: Type
f = True
Note that the -ddump-splices
output displays f :: Bool :: Type
. This is not valid code, since trying to copy-paste this into a file will make GHC produce a parse error:
$ ghc-9.4.4 Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o, Bug.dyn_o ) [Source file changed]
Bug.hs:13:11: error: parse error on input ‘::’
|
13 | f :: Bool :: Type
| ^^
Most likely, there is a missing call to parenthesizeHsType
somewhere in GHC.ThToHs
. I will investigate.