Skip to content

Pretty-printing of promotion quotes and char literals

This issue is a sequel to #14343 (closed). When pretty-printing a promoted tuple or list, we are careful to add a space after the opening bracket if the inner type also starts with a promotion quote:

ghci> type T = '[ '[1] ]
ghci> :kind! T
T :: [[Natural]]
= '[ '[1]]

This is correct and if we didn't add a space there, we'd print '['[1]], which does not parse due to confusion with a character literal '['.

The logic responsible for this resides in pprSpaceIfPromotedTyCon.

Alas, what it fails to consider is the possibility that the inner type is itself a character literal:

ghci> type T = '[ 'x' ]
ghci> :kind! T
T :: [Char]
= '['x']
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information