-\begin{code}
-pprHsVar :: Outputable name => name -> SDoc
-pprHsVar v | isOperator ppr_v = parens ppr_v
- | otherwise = ppr_v
- where
- ppr_v = ppr v
-
-isOperator :: SDoc -> Bool
-isOperator ppr_v
- = case showSDocUnqual ppr_v of
- ('(':s) -> False -- (), (,) etc
- ('[':s) -> False -- []
- ('$':c:s) -> not (isAlpha c) -- Don't treat $d as an operator
- (':':c:s) -> not (isAlpha c) -- Don't treat :T as an operator
- ('_':s) -> False -- Not an operator
- (c:s) -> not (isAlpha c) -- Starts with non-alpha
- other -> False
- -- We use (showSDoc (ppr v)), rather than isSymOcc (getOccName v) simply so
- -- that we don't need NamedThing in the context of all these functions.
- -- Gruesome, but simple.
-\end{code}