From e0963b10b121f9eb1545295184e64ca3f340a00f Mon Sep 17 00:00:00 2001 From: krasimir Date: Thu, 18 Aug 2005 20:32:47 +0000 Subject: [PATCH] [project @ 2005-08-18 20:32:46 by krasimir] 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 | 4 ++-- ghc/compiler/types/InstEnv.lhs | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ghc/compiler/main/GHC.hs b/ghc/compiler/main/GHC.hs index a7b709c..938757b 100644 --- a/ghc/compiler/main/GHC.hs +++ b/ghc/compiler/main/GHC.hs @@ -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 ) diff --git a/ghc/compiler/types/InstEnv.lhs b/ghc/compiler/types/InstEnv.lhs index 03d65a0..d4a7b77 100644 --- a/ghc/compiler/types/InstEnv.lhs +++ b/ghc/compiler/types/InstEnv.lhs @@ -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 -- 1.7.10.4