-ddump-splices prints ParensT/HsArgPar poorly
If you compile this program:
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -ddump-splices #-}
module Bug where
import Language.Haskell.TH
type family T a
$(pure [TySynInstD (TySynEqn Nothing (ParensT (ConT ''T) `AppT` ConT ''Int) (ConT ''Int))])
Then -ddump-splices
will print this:
$ /opt/ghc/9.0.1/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o, Bug.dyn_o )
Bug.hs:10:2-91: Splicing declarations
pure
[TySynInstD
(TySynEqn
Nothing (ParensT (ConT ''T) `AppT` ConT ''Int) (ConT ''Int))]
======>
type instance T HsArgPar Bug.hs:10:2-91 Int = Int
In particular, notice that the type family instance is printed as type instance T HsArgPar Bug.hs:10:2-91 Int = Int
rather than type instance (T) Int = Int
. This happens because pprHsFamInstLHS
uses the Outputable
instance for HsArg
to pretty-print the types on the left-hand side:
nstance (Outputable tm, Outputable ty) => Outputable (HsArg tm ty) where
ppr (HsValArg tm) = ppr tm
ppr (HsTypeArg _ ty) = char '@' <> ppr ty
ppr (HsArgPar sp) = text "HsArgPar" <+> ppr sp
Most likely, we'll need to avoid using this Outputable
instance when pretty-printing Haskell code, such as what -ddump-splices
does.