[GHC] #779: small bugs in Language.Haskell.TH.Ppr.pprint
GHC
trac at galois.com
Tue Jun 6 23:27:52 EDT 2006
#779: small bugs in Language.Haskell.TH.Ppr.pprint
----------------------------------------+-----------------------------------
Reporter: skata at cs.miyazaki-u.ac.jp | Owner:
Type: bug | Status: closed
Priority: normal | Milestone:
Component: Template Haskell | Version: 6.5
Severity: minor | Resolution: fixed
Keywords: | Os: Multiple
Difficulty: Easy (1 hr) | Architecture: Multiple
----------------------------------------+-----------------------------------
Comment (by skata at cs.miyazaki-u.ac.jp):
Seemingly I am not allowed to post to libraries at haskell.org, but because
the patch is not long I paste the result of "darcs send --output FILE"
here. Thank you.
{{{
New patches:
[bugfix for TH.pprint not printing parentheses of higher-order functions
skata at cs.miyazaki-u.ac.jp**20060605070154
fix for Problem 1 of Ticket #779
] {
hunk ./Language/Haskell/TH/Ppr.hs 287
-pprTyApp (ArrowT, [arg1,arg2]) = sep [ppr arg1 <+> text "->", ppr arg2]
+pprTyApp (ArrowT, [arg1,arg2]) = sep [ppr' arg1 <+> text "->", ppr arg2]
+ where ppr' t@(AppT (AppT ArrowT _) _) = parens (ppr t)
+ ppr' t = ppr t
}
[bugfix for TH.pprint not parenthesizing operators used as functions
skata at cs.miyazaki-u.ac.jp**20060605070623
fixes Problem 2 of Ticket #779
] {
hunk ./Language/Haskell/TH/Ppr.hs 79
+isOp :: Exp -> Bool
+isOp (VarE v) = case nameBase v of c:_ | c `elem` "!#$%&~=|+*<>?-^@:./\\"
+ -> True
+ _ -> False
+isOp (ConE c) = case nameBase c of ':':_ -> True
+ _ -> False
+isOp _ = False
+
hunk ./Language/Haskell/TH/Ppr.hs 91
-pprExp i (AppE e1 e2) = parensIf (i >= appPrec) $ pprExp opPrec e1
- <+> pprExp appPrec e2
+pprExp i (AppE e1 e2)
+ = parensIf (i >= appPrec) $ parensIf (isOp e1) (pprExp opPrec e1)
+ <+> pprExp appPrec e2
}
Context:
[Drop dependency to haskell98 package
Einar Karttunen <ekarttun at cs.helsinki.fi>**20060209224626]
[TAG Initial conversion from CVS complete
John Goerzen <jgoerzen at complete.org>**20060112154138]
Patch bundle hash:
6fe9ad707d47f4b7c0ceb127bf8c0ba1e461a0dc
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/779>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list