[GHC] #842: pretty-printing bug in Template Haskell library

GHC trac at galois.com
Thu Aug 3 05:06:31 EDT 2006


#842: pretty-printing bug in Template Haskell library
--------------------------------------+-------------------------------------
    Reporter:  devnull1999 at yahoo.com  |        Owner:             
        Type:  bug                    |       Status:  new        
    Priority:  normal                 |    Milestone:             
   Component:  libraries (other)      |      Version:  6.4.2      
    Severity:  normal                 |     Keywords:             
          Os:  Unknown                |   Difficulty:  Easy (1 hr)
Architecture:  Unknown                |  
--------------------------------------+-------------------------------------
It can quickly be seen in ghci but occurs in any compiler using the
 libraries:

 {{{
 ghci -fth

 :module Language.Haskell.TH
 runQ [d| foo (Just _) = True|] >>= putStrLn . pprint

 foo Data.Maybe.Just _ = GHC.Base.True
 }}}

 Note: the Just term is no longer parenthesized.

 Problem is in Language.Haskell.TH.Ppr where

 {{{
 instance Ppr Clause where
     ppr (Clause ps rhs ds) = hsep (map ppr ps) <+> pprBody True rhs
                           $$ where_clause ds
 }}}

 should read:

 {{{
 instance Ppr Clause where
     ppr (Clause ps rhs ds) = hsep (map (pprPat appPrec) ps) <+> pprBody
 True rhs
                           $$ where_clause ds
 }}}
 because the Clause follows a function name and so is always inside a
 surrounding function application.

 (It also wouldn't hurt to change

 {{{
 instance Ppr Con where
     ppr (NormalC c sts) = ppr c <+> hsep (map pprStrictType sts)
     ppr (RecC c vsts)
         = ppr c <+> braces (hsep (punctuate comma $ map pprVarStrictType
 vsts))
 }}}

 to

 {{{
 instance Ppr Con where
     ppr (NormalC c sts) = ppr c <+> hsep (map pprStrictType sts)
     ppr (RecC c vsts)
         = ppr c <+> braces (vcat (punctuate comma $ map pprVarStrictType
 vsts))
 }}}
 just for esthetics.  Record fields run off the page very quickly.)

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/842>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the Glasgow-haskell-bugs mailing list