pprDec bug

Daniel Brown <[email protected]>
Newsgroups gmane.comp.lang.haskell.template
Message-ID <[email protected]>
I'm using GHCi version 6.2.1 under Cygwin.  I'm trying to implement a
compiler that translates a DSL into Haskell; I'd like to build the
structure incrementally and then use the pretty printer to output the
target code.  However, the pretty printer does not always produce
valid output; sometimes needed parentheses are lacking, as in:

    Main> pprDec $ DataD [] "M" [] [NormalC "M" [(NotStrict, AppT (ConT Maybe) (ConT "Int"))]] []
    data M = M Maybe Int

Related question: I've defined a utility function

> pdq decq = runQ decq >>= mapM_ print . map pprDec

so I can pretty-print declarations in code brackets, viz.:

    Main> pdq [d| data M = M (Maybe Int) |]

Is there an easy way to transform the declaration to use the
short forms of type names, e.g. "Int" instead of "GHC.Base:Int"?

-- Dan.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.