-- Construction
mkRdrUnqual, mkRdrQual,
- mkUnqual, mkVarUnqual, mkQual, mkOrig, mkIfaceOrig,
+ mkUnqual, mkVarUnqual, mkQual, mkOrig,
nameRdrName, getRdrName,
- qualifyRdrName, unqualifyRdrName,
mkDerivedRdrName,
- dummyRdrVarName, dummyRdrTcName,
-- Destruction
rdrNameModule, rdrNameOcc, setRdrNameSpace,
isOrig, isOrig_maybe, isExact, isExact_maybe, isSrcRdrName,
-- Printing; instance Outputable RdrName
- pprUnqualRdrName,
-- LocalRdrEnv
LocalRdrEnv, emptyLocalRdrEnv, extendLocalRdrEnv,
-- GlobalRdrElt, Provenance, ImportSpec
GlobalRdrElt(..), Provenance(..), ImportSpec(..),
- isLocalGRE, unQualOK, hasQual,
+ isLocalGRE, unQualOK,
pprNameProvenance
) where
import Name ( Name, NamedThing(getName), nameModuleName, nameParent_maybe,
nameOccName, isExternalName, nameSrcLoc )
import Maybes ( seqMaybe )
-import SrcLoc ( SrcLoc, isGoodSrcLoc )
+import SrcLoc ( SrcLoc, isGoodSrcLoc, SrcSpan )
import BasicTypes( DeprecTxt )
import Outputable
import Util ( thenCmp )
mkOrig :: ModuleName -> OccName -> RdrName
mkOrig mod occ = Orig mod occ
-mkIfaceOrig :: NameSpace -> EncodedFS -> EncodedFS -> RdrName
-mkIfaceOrig ns m n = Orig (mkSysModuleNameFS m) (mkSysOccFS ns n)
-
---------------
mkDerivedRdrName :: Name -> (OccName -> OccName) -> (RdrName)
mkDerivedRdrName parent mk_occ
-- unique is still there for debug printing, particularly
-- of Types (which are converted to IfaceTypes before printing)
-qualifyRdrName :: ModuleName -> RdrName -> RdrName
- -- Sets the module name of a RdrName, even if it has one already
-qualifyRdrName mod rn = Qual mod (rdrNameOcc rn)
-
-unqualifyRdrName :: RdrName -> RdrName
-unqualifyRdrName rdr_name = Unqual (rdrNameOcc rdr_name)
-
nukeExact :: Name -> RdrName
nukeExact n
| isExternalName n = Orig (nameModuleName n) (nameOccName n)
\end{code}
\begin{code}
- -- This guy is used by the reader when HsSyn has a slot for
- -- an implicit name that's going to be filled in by
- -- the renamer. We can't just put "error..." because
- -- we sometimes want to print out stuff after reading but
- -- before renaming
-dummyRdrVarName = Unqual (mkVarOcc FSLIT("V-DUMMY"))
-dummyRdrTcName = Unqual (mkOccFS tcName FSLIT("TC-DUMMY"))
-\end{code}
-
-
-\begin{code}
isRdrDataCon rn = isDataOcc (rdrNameOcc rn)
isRdrTyVar rn = isTvOcc (rdrNameOcc rn)
isRdrTc rn = isTcOcc (rdrNameOcc rn)
| isTvOcc (rdrNameOcc n) = char '@' <+> ppr n
| otherwise = ppr n
-pprUnqualRdrName rdr_name = ppr (rdrNameOcc rdr_name)
-
instance Eq RdrName where
(Exact n1) == (Exact n2) = n1==n2
-- Convert exact to orig
-- the defining module for this thing!
is_as :: ModuleName, -- 'as M' (or 'Muggle' if there is no 'as' clause)
is_qual :: Bool, -- True <=> qualified (only)
- is_loc :: SrcLoc } -- Location of import statment
+ is_loc :: SrcSpan } -- Location of import statment
-- Comparison of provenance is just used for grouping
-- error messages (in RnEnv.warnUnusedBinds)
pprNameProvenance (GRE {gre_name = name, gre_prov = LocalDef _})
= ptext SLIT("defined at") <+> ppr (nameSrcLoc name)
pprNameProvenance (GRE {gre_name = name, gre_prov = Imported (why:whys) _})
- = sep [ppr_reason why, nest 2 (ppr_defn (nameSrcLoc name))]
+ = sep [ppr why, nest 2 (ppr_defn (nameSrcLoc name))]
-ppr_reason imp_spec
- = ptext SLIT("imported from") <+> ppr (is_mod imp_spec)
+instance Outputable ImportSpec where
+ ppr imp_spec
+ = ptext SLIT("imported from") <+> ppr (is_mod imp_spec)
<+> ptext SLIT("at") <+> ppr (is_loc imp_spec)
ppr_defn loc | isGoodSrcLoc loc = parens (ptext SLIT("defined at") <+> ppr loc)