Skip to content

TH pretty-printer prints symbol names in `type role` declarations without parens

Language.Haskell.TH.Ppr.pprint prints the name of a type in type role declaration without checking if it's a symbol and therefore should be parenthesized.

Steps to reproduce

$ ghci -XRoleAnnotations -XTemplateHaskell
GHCi, version 9.6.2: https://www.haskell.org/ghc/  :? for help
ghci> Language.Haskell.TH.runQ [d|data a ## b; type role (##) nominal nominal|] >>= putStrLn . Language.Haskell.TH.Ppr.pprint
data (##_0) a_1 b_2
type role ##_0 nominal nominal

Expected behavior

The output on the last line above should be

type role (##_0) nominal nominal

Environment

  • GHC version used: 9.6.2
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information