|
[GHC] #779: small bugs in Language.Haskell.TH.Ppr.pprint: msg#00112lang.haskell.glasgow.bugs
#779: small bugs in Language.Haskell.TH.Ppr.pprint ----------------------------------------+----------------------------------- Reporter: skata@xxxxxxxxxxxxxxxxxxx | Owner: Type: bug | Status: new Priority: normal | Milestone: 6.4.2 Component: Template Haskell | Version: 6.5 Severity: minor | Keywords: Difficulty: Easy (1 hr) | Architecture: Multiple Os: Multiple | ----------------------------------------+----------------------------------- Thank you very much for developing GHC. I would like to report two small bugs and my patch for them. (These problems apply at least to 6.4.1, 6.4.2, and the current 6.5 in the darcs repository) Problem 1: pprint does not deal with parentheses of types of higher-order functions correctly, i.e.: [skata@mermaid]~% ghci -fth -v0[[BR]] Prelude> Language.Haskell.TH.runQ [t| (Int->Int)->Int |] >>= \e -> putStrLn (Language.Haskell.TH.pprint e)[[BR]] Loading package template-haskell-1.0 ... linking ... done.[[BR]] GHC.Base.Int -> GHC.Base.Int -> GHC.Base.Int I believe '(GHC.Base.Int -> GHC.Base.Int) -> GHC.Base.Int' should be printed. Problem 2: pprint does not parenthesize operators used as functions, e.g.: Prelude> Language.Haskell.TH.runQ [| (.) id id |] >>= \e -> putStrLn (Language.Haskell.TH.pprint e)[[BR]] GHC.Base.. GHC.Base.id GHC.Base.id I think 'GHC.Base..' should be parenthesized. Patch: Hopefully the following patch works (at least for me): `== running darcs whatsnew in libraries/template-haskell`[[BR]] `{`[[BR]] `hunk ./Language/Haskell/TH/Ppr.hs 42`[[BR]] `- ppr v = pprName v -- text (show v)`[[BR]] `+ ppr v = case nameBase v of c:_ | c `elem` "!#$%&~=|+*<>?-^@:./\\"`[[BR]] `+ -> parens (pprName v)`[[BR]] `+ _ -> pprName v`[[BR]] `hunk ./Language/Haskell/TH/Ppr.hs 289`[[BR]] `-pprTyApp (ArrowT, [arg1,arg2]) = sep [ppr arg1 <+> text "->", ppr arg2]`[[BR]] `+pprTyApp (ArrowT, [arg1,arg2]) = sep [ppr' arg1 <+> text "->", ppr arg2]`[[BR]] `+ where ppr' t = case split t of (ArrowT, [_,_]) -> parens (ppr t)`[[BR]] `+ _ -> ppr t`[[BR]] `}`[[BR]] Best regards, -- 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> |
|---|---|---|
| Previous by Date: | Re: [GHC] #778: memory leak, GHC |
|---|---|
| Next by Date: | solutions for errors installing ghc-6.4.1 (Mac OS X 10.4.6, Xcode 2.2.1), Rich Talley |
| Previous by Thread: | [GHC] #778: memory leak, GHC |
| Next by Thread: | solutions for errors installing ghc-6.4.1 (Mac OS X 10.4.6, Xcode 2.2.1), Rich Talley |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |