Ticket #779: pprint.patch

File pprint.patch, 1.5 KB (added by skata@…, 8 years ago)
Line 
1
2New patches:
3
4[bugfix for TH.pprint not printing parentheses of higher-order functions
5skata@cs.miyazaki-u.ac.jp**20060605070154
6 fix for Problem 1 of Ticket #779
7] {
8hunk ./Language/Haskell/TH/Ppr.hs 287
9-pprTyApp (ArrowT, [arg1,arg2]) = sep [ppr arg1 <+> text "->", ppr arg2]
10+pprTyApp (ArrowT, [arg1,arg2]) = sep [ppr' arg1 <+> text "->", ppr arg2]
11+  where ppr' t@(AppT (AppT ArrowT _) _) = parens (ppr t)
12+        ppr' t                         = ppr t
13}
14
15[bugfix for TH.pprint not parenthesizing operators used as functions
16skata@cs.miyazaki-u.ac.jp**20060605070623
17 fixes Problem 2 of Ticket #779
18] {
19hunk ./Language/Haskell/TH/Ppr.hs 79
20+isOp :: Exp -> Bool
21+isOp (VarE v) = case nameBase v of c:_ | c `elem` "!#$%&~=|+*<>?-^@:./\\"
22+                                                    -> True
23+                                   _                -> False
24+isOp (ConE c) = case nameBase c of ':':_ -> True
25+                                   _     -> False
26+isOp _        = False
27+
28hunk ./Language/Haskell/TH/Ppr.hs 91
29-pprExp i (AppE e1 e2) = parensIf (i >= appPrec) $ pprExp opPrec e1
30-                                              <+> pprExp appPrec e2
31+pprExp i (AppE e1 e2)
32+ = parensIf (i >= appPrec) $ parensIf (isOp e1) (pprExp opPrec e1)
33+                         <+> pprExp appPrec e2
34}
35
36Context:
37
38[Drop dependency to haskell98 package
39Einar Karttunen <ekarttun@cs.helsinki.fi>**20060209224626]
40[TAG Initial conversion from CVS complete
41John Goerzen <jgoerzen@complete.org>**20060112154138]
42Patch bundle hash:
436fe9ad707d47f4b7c0ceb127bf8c0ba1e461a0dc