[project @ 2005-08-18 20:32:46 by krasimir]
authorkrasimir <unknown>
Thu, 18 Aug 2005 20:32:47 +0000 (20:32 +0000)
committerkrasimir <unknown>
Thu, 18 Aug 2005 20:32:47 +0000 (20:32 +0000)
add pprInstanceHdr function. It is analogous to pprTyThingHdr and prints the
instance but without the "-- Defined at ...." comment. The function is used in
VStudio to populate the ClassView tree.

ghc/compiler/main/GHC.hs
ghc/compiler/types/InstEnv.lhs

index a7b709c..938757b 100644 (file)
@@ -120,7 +120,7 @@ module GHC (
 
        -- ** Instances
        Instance, 
-       instanceDFunId, pprInstance,
+       instanceDFunId, pprInstance, pprInstanceHdr,
 
        -- ** Types and Kinds
        Type, dropForAlls, splitForAllTys, funResultTy, pprParendType,
@@ -204,7 +204,7 @@ import Name         ( Name, nameModule, NamedThing(..), nameParent_maybe,
                          nameSrcLoc )
 import OccName         ( parenSymOcc )
 import NameEnv         ( nameEnvElts )
-import InstEnv         ( Instance, instanceDFunId, pprInstance )
+import InstEnv         ( Instance, instanceDFunId, pprInstance, pprInstanceHdr )
 import SrcLoc
 import DriverPipeline
 import DriverPhases    ( Phase(..), isHaskellSrcFilename, startPhase )
index 03d65a0..d4a7b77 100644 (file)
@@ -8,7 +8,7 @@ The bits common to TcInstDcls and TcDeriv.
 \begin{code}
 module InstEnv (
        DFunId, OverlapFlag(..),
-       Instance(..), pprInstance, pprInstances, 
+       Instance(..), pprInstance, pprInstanceHdr, pprInstances, 
        instanceHead, mkLocalInstance, mkImportedInstance,
        instanceDFunId, setInstanceDFunId, instanceRoughTcs,
 
@@ -153,9 +153,15 @@ instance Outputable Instance where
 pprInstance :: Instance -> SDoc
 -- Prints the Instance as an instance declaration
 pprInstance ispec@(Instance { is_flag = flag })
-  = hang (ptext SLIT("instance") <+> ppr flag
-         <+> sep [pprThetaArrow theta, pprClassPred clas tys])
+  = hang (pprInstanceHdr ispec)
        2 (ptext SLIT("--") <+> (pprDefnLoc (getSrcLoc ispec)))
+
+-- * pprInstanceHdr is used in VStudio to populate the ClassView tree
+pprInstanceHdr :: Instance -> SDoc
+-- Prints the Instance as an instance declaration
+pprInstanceHdr ispec@(Instance { is_flag = flag })
+  = ptext SLIT("instance") <+> ppr flag
+    <+> sep [pprThetaArrow theta, pprClassPred clas tys]
   where
     (_, theta, clas, tys) = instanceHead ispec
        -- Print without the for-all, which the programmer doesn't write