logo       

Re: [GHC] #779: small bugs in Language.Haskell.TH.Ppr.pprint: msg#00051

lang.haskell.glasgow.bugs

Subject: Re: [GHC] #779: small bugs in Language.Haskell.TH.Ppr.pprint

#779: small bugs in Language.Haskell.TH.Ppr.pprint
----------------------------------------+-----------------------------------
Reporter: skata@xxxxxxxxxxxxxxxxxxx | 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@xxxxxxxxxxxxxxxxxxx):

Seemingly I am not allowed to post to libraries@xxxxxxxxxxx, 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@xxxxxxxxxxxxxxxxxxx**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@xxxxxxxxxxxxxxxxxxx**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@xxxxxxxxxxxxxx>**20060209224626]
[TAG Initial conversion from CVS complete
John Goerzen <jgoerzen@xxxxxxxxxxxx>**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_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@xxxxxxxxxxx
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise