TH pretty-printer emits a syntactically invalid representation of an unboxed sum type
Summary
A tuple type or sum type are represented in Template Haskell as a chain of AppT
s starting with a tuple or sum constructor. The pretty-printer contains logic to print a boxed tuple chain like TupleT 3 `AppT` a `AppT` b `AppT` c
prettily as (a, b, c)
.
For unboxed tuples however the corresponding output will be (# ,, #) a b c
. Not pretty, but valid. An unboxed sum unfortunately is shown as (# || #) a b c
which is both ugly and invalid: the ||
parses as a single token.
Steps to reproduce
$ ghci -XUnboxedTuples -XTemplateHaskell
GHCi, version 9.10.1: https://www.haskell.org/ghc/ :? for help
ghci> Language.Haskell.TH.runQ [t| (# Int | Char | Bool #) |] >>= putStrLn . Language.Haskell.TH.Ppr.pprint
(# || #) GHC.Types.Int GHC.Types.Char GHC.Types.Bool
Expected behavior
(# | | #) GHC.Types.Int GHC.Types.Char GHC.Types.Bool
or better yet
(# GHC.Types.Int | GHC.Types.Char | GHC.Types.Bool #)
Environment
- GHC version used: 9.10.1
Edited by Mario