X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Fmain%2FPprTyThing.hs;h=ecf69476cd040a5c44c43d92848745911e0e5245;hb=07806d2b66986825ff7c5cd51240f920d91ee2f9;hp=fc53e72a64bee574c5a64be8e038d3099ac66b70;hpb=e6de067858737daac62fe9066f6bda308c5616c3;p=ghc-hetmet.git diff --git a/ghc/compiler/main/PprTyThing.hs b/ghc/compiler/main/PprTyThing.hs index fc53e72..ecf6947 100644 --- a/ghc/compiler/main/PprTyThing.hs +++ b/ghc/compiler/main/PprTyThing.hs @@ -11,6 +11,7 @@ module PprTyThing ( pprTyThingInContext, pprTyThingLoc, pprTyThingInContextLoc, + pprTyThingHdr ) where #include "HsVersions.h" @@ -53,12 +54,22 @@ pprTyThingInContext exts (AnId id) = pprIdInContext exts id pprTyThingInContext exts (ADataCon dataCon) = pprDataCon exts dataCon pprTyThingInContext exts (ATyCon tyCon) = pprTyCon exts tyCon pprTyThingInContext exts (AClass cls) = pprClass exts cls + +-- | Pretty-prints the 'TyThing' header. For functions and data constructors +-- the function is equivalent to 'pprTyThing' but for type constructors +-- and classes it prints only the header part of the declaration. +pprTyThingHdr :: Bool -> TyThing -> SDoc +pprTyThingHdr exts (AnId id) = pprId exts id +pprTyThingHdr exts (ADataCon dataCon) = pprDataConSig exts dataCon +pprTyThingHdr exts (ATyCon tyCon) = pprTyConHdr exts tyCon +pprTyThingHdr exts (AClass cls) = pprClassHdr exts cls pprTyConHdr exts tyCon = ptext keyword <+> ppr_bndr tyCon <+> hsep (map ppr vars) where - vars = GHC.tyConTyVars tyCon - + vars | GHC.isPrimTyCon tyCon = take (GHC.tyConArity tyCon) GHC.alphaTyVars + | otherwise = GHC.tyConTyVars tyCon + keyword | GHC.isSynTyCon tyCon = SLIT("type") | GHC.isNewTyCon tyCon = SLIT("newtype") | otherwise = SLIT("data")