diff options
author | Malo Jaffré <jaffre.malo@gmail.com> | 2016-09-01 14:13:47 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2016-09-01 15:05:16 -0400 |
commit | f233f00b1915ac6c0a200b8017a9f07deefd401e (patch) | |
tree | 0dc9eaa34f6754564ef2869e67e3ce381ea766a8 /libraries/template-haskell | |
parent | b946cf3f5d6fd273a79b008472e8cb0ad1432be1 (diff) | |
download | haskell-f233f00b1915ac6c0a200b8017a9f07deefd401e.tar.gz |
Fix startsVarSym and refactor operator predicates (fixes #4239)
startsVarSym used isSymbol which does not recognize valid operators
beginning with OtherPunctuation generalCategory (e. g. (·)).
Move it to ghc-boot-th for reducing duplication.
This patch fixes template-haskell pretty printer, which is used by
-ddump-minimal-imports.
Reviewers: austin, bgamari
Reviewed By: bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2480
GHC Trac Issues: #4239
Diffstat (limited to 'libraries/template-haskell')
-rw-r--r-- | libraries/template-haskell/Language/Haskell/TH/Ppr.hs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/libraries/template-haskell/Language/Haskell/TH/Ppr.hs b/libraries/template-haskell/Language/Haskell/TH/Ppr.hs index bdd4dd388a..0462a8da25 100644 --- a/libraries/template-haskell/Language/Haskell/TH/Ppr.hs +++ b/libraries/template-haskell/Language/Haskell/TH/Ppr.hs @@ -10,8 +10,9 @@ import Text.PrettyPrint (render) import Language.Haskell.TH.PprLib import Language.Haskell.TH.Syntax import Data.Word ( Word8 ) -import Data.Char ( toLower, chr, ord, isSymbol ) +import Data.Char ( toLower, chr) import GHC.Show ( showMultiLineString ) +import GHC.Lexeme( startsVarSym ) import Data.Ratio ( numerator, denominator ) nestDepth :: Int @@ -114,12 +115,9 @@ isSymOcc :: Name -> Bool isSymOcc n = case nameBase n of [] -> True -- Empty name; weird - (c:_) -> isSymbolASCII c || (ord c > 0x7f && isSymbol c) + (c:_) -> startsVarSym c -- c.f. OccName.startsVarSym in GHC itself -isSymbolASCII :: Char -> Bool -isSymbolASCII c = c `elem` "!#$%&*+./<=>?@\\^|~-" - pprInfixExp :: Exp -> Doc pprInfixExp (VarE v) = pprName' Infix v pprInfixExp (ConE v) = pprName' Infix v |