TH can't attach docs to type operators that don't start with `:`
Summary
When compiling the below module, GHC fails with:
Bug.hs:1:1: error: [GHC-24922] ‘>-:’ is not in scope at a reify
|
1 | {-# LANGUAGE TemplateHaskell #-}
| ^
Steps to reproduce
{-# LANGUAGE TemplateHaskell #-}
module Bug where
import Language.Haskell.TH
$(sequence [withDecDoc "doc string" $ tySynD (mkName ">-:") [] [t| () |]])
Note that using mkName ":->"
instead succeeds.
Expected behavior
I expect this to compile regardless of whether the type operator name begins with :
.
Possibly related: #11046 (closed)
I have a notion of fixing this here: https://gitlab.haskell.org/ghc/ghc/-/blob/420000000e2d3d1a07ff3aa2a24cc88bd3d48e75/compiler/GHC/ThToHs.hs#L2180-2181
isLexCon
returns true if a symbol is data-constructor-like, but type constructors can also have names that are variable-like symbols. Maybe insert the below as a third branch?
| isLexVarSym (mkFastString occ_str) = [OccName.tcName, OccName.varName]
Would that be correct?
Environment
- GHC version used: 9.6.2
Optional:
- Operating System: Linux (NixOS)
- System Architecture: x86_64