Skip to content

TH pretty-printer uses wrong syntax for GADT newtype

Summary

When given a newtype declaration with a GADT constructor, Template Haskell's pprint emits an = separator instead of where. That's wrong syntax that couldn't be parsed.

Steps to reproduce

$ ghci-9.2.1 
GHCi, version 9.2.1: https://www.haskell.org/ghc/  :? for help
ghci> :set -XTemplateHaskell -XGADTs
ghci> Language.Haskell.TH.runQ [d| newtype MyType where { MyType :: Bool -> MyType } |] >>= putStrLn . Language.Haskell.TH.Ppr.pprint
newtype MyType_0 = MyType_1 :: GHC.Types.Bool -> MyType_0

Expected behavior

newtype MyType_0 where MyType_1 :: GHC.Types.Bool -> MyType_0

or

newtype MyType_0
    where MyType_1 :: GHC.Types.Bool -> MyType_0

Environment

  • GHC version used: 9.2.1

Optional:

  • Operating System:
  • System Architecture:
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information