This has been a long-standing ToDo.
-- UserLocal: an Id with a name the user might recognize...
-mkUserLocal :: OccName -> Unique -> Type -> SrcLoc -> Id
+mkUserLocal :: OccName -> Unique -> Type -> SrcSpan -> Id
mkVanillaGlobal :: Name -> Type -> IdInfo -> Id
mkUserLocal occ uniq ty loc = mkLocalId (mkInternalName uniq occ loc) ty
mkWorkerId uniq unwrkr ty
= mkLocalId wkr_name ty
where
- wkr_name = mkInternalName uniq (mkWorkerOcc (getOccName unwrkr)) (getSrcLoc unwrkr)
+ wkr_name = mkInternalName uniq (mkWorkerOcc (getOccName unwrkr)) (getSrcSpan unwrkr)
-- "Template locals" typically used in unfoldings
mkTemplateLocals :: [Type] -> [Id]
tidyNameOcc,
hashName, localiseName,
- nameSrcLoc,
+ nameSrcLoc, nameSrcSpan,
isSystemName, isInternalName, isExternalName,
isTyVarName, isTyConName, isWiredInName, isBuiltInSyntax,
-- Class NamedThing and overloaded friends
NamedThing(..),
- getSrcLoc, getOccString
+ getSrcLoc, getSrcSpan, getOccString
) where
#include "HsVersions.h"
n_sort :: NameSort, -- What sort of name it is
n_occ :: !OccName, -- Its occurrence name
n_uniq :: Int#, -- UNPACK doesn't work, recursive type
- n_loc :: !SrcLoc -- Definition site
+ n_loc :: !SrcSpan -- Definition site
}
-- NOTE: we make the n_loc field strict to eliminate some potential
nameOccName :: Name -> OccName
nameModule :: Name -> Module
nameSrcLoc :: Name -> SrcLoc
+nameSrcSpan :: Name -> SrcSpan
nameUnique name = mkUniqueGrimily (I# (n_uniq name))
nameOccName name = n_occ name
-nameSrcLoc name = n_loc name
+nameSrcLoc name = srcSpanStart (n_loc name)
+nameSrcSpan name = n_loc name
\end{code}
\begin{code}
%************************************************************************
\begin{code}
-mkInternalName :: Unique -> OccName -> SrcLoc -> Name
+mkInternalName :: Unique -> OccName -> SrcSpan -> Name
mkInternalName uniq occ loc = Name { n_uniq = getKey# uniq, n_sort = Internal, n_occ = occ, n_loc = loc }
-- NB: You might worry that after lots of huffing and
-- puffing we might end up with two local names with distinct
-- * for interface files we tidyCore first, which puts the uniques
-- into the print name (see setNameVisibility below)
-mkExternalName :: Unique -> Module -> OccName -> SrcLoc -> Name
+mkExternalName :: Unique -> Module -> OccName -> SrcSpan -> Name
mkExternalName uniq mod occ loc
= Name { n_uniq = getKey# uniq, n_sort = External mod,
n_occ = occ, n_loc = loc }
mkWiredInName mod occ uniq thing built_in
= Name { n_uniq = getKey# uniq,
n_sort = WiredIn mod thing built_in,
- n_occ = occ, n_loc = wiredInSrcLoc }
+ n_occ = occ, n_loc = wiredInSrcSpan }
mkSystemName :: Unique -> OccName -> Name
mkSystemName uniq occ = Name { n_uniq = getKey# uniq, n_sort = System,
- n_occ = occ, n_loc = noSrcLoc }
+ n_occ = occ, n_loc = noSrcSpan }
mkSystemVarName :: Unique -> FastString -> Name
mkSystemVarName uniq fs = mkSystemName uniq (mkVarOccFS fs)
mkFCallName :: Unique -> String -> Name
-- The encoded string completely describes the ccall
mkFCallName uniq str = Name { n_uniq = getKey# uniq, n_sort = Internal,
- n_occ = mkVarOcc str, n_loc = noSrcLoc }
+ n_occ = mkVarOcc str, n_loc = noSrcSpan }
mkTickBoxOpName :: Unique -> String -> Name
mkTickBoxOpName uniq str
= Name { n_uniq = getKey# uniq, n_sort = Internal,
- n_occ = mkVarOcc str, n_loc = noSrcLoc }
+ n_occ = mkVarOcc str, n_loc = noSrcSpan }
mkIPName :: Unique -> OccName -> Name
mkIPName uniq occ
= Name { n_uniq = getKey# uniq,
n_sort = Internal,
n_occ = occ,
- n_loc = noSrcLoc }
+ n_loc = noSrcSpan }
\end{code}
\begin{code}
\begin{code}
getSrcLoc :: NamedThing a => a -> SrcLoc
+getSrcSpan :: NamedThing a => a -> SrcSpan
getOccString :: NamedThing a => a -> String
getSrcLoc = nameSrcLoc . getName
+getSrcSpan = nameSrcSpan . getName
getOccString = occNameString . getOccName
\end{code}
advanceSrcLoc,
importedSrcLoc, -- Unknown place in an interface
- wiredInSrcLoc, -- Something wired into the compiler
generatedSrcLoc, -- Code generated within the compiler
interactiveSrcLoc, -- Code from an interactive session
SrcSpan, -- Abstract
noSrcSpan,
+ wiredInSrcSpan, -- Something wired into the compiler
+ importedSrcSpan, -- Unknown place in an interface
mkGeneralSrcSpan,
isGoodSrcSpan, isOneLineSpan,
mkSrcSpan, srcLocSpan,
-- Don't ask me why lines start at 1 and columns start at
-- zero. That's just the way it is, so there. --SDM
- | ImportedLoc String -- Module name
+ | ImportedLoc FastString -- Module name
| UnhelpfulLoc FastString -- Just a general indication
\end{code}
mkSrcLoc x line col = SrcLoc x line col
noSrcLoc = UnhelpfulLoc FSLIT("<no location info>")
generatedSrcLoc = UnhelpfulLoc FSLIT("<compiler-generated code>")
-wiredInSrcLoc = UnhelpfulLoc FSLIT("<wired into compiler>")
interactiveSrcLoc = UnhelpfulLoc FSLIT("<interactive session>")
mkGeneralSrcLoc :: FastString -> SrcLoc
mkGeneralSrcLoc = UnhelpfulLoc
-importedSrcLoc :: String -> SrcLoc
+importedSrcLoc :: FastString -> SrcLoc
importedSrcLoc mod_name = ImportedLoc mod_name
isGoodSrcLoc (SrcLoc _ _ _) = True
hcat [text "{-# LINE ", int src_line, space,
char '\"', ftext src_path, text " #-}"]
- ppr (ImportedLoc mod) = ptext SLIT("Defined in") <+> text mod
+ ppr (ImportedLoc mod) = ptext SLIT("Defined in") <+> ftext mod
ppr (UnhelpfulLoc s) = ftext s
\end{code}
srcSpanCol :: !Int
}
- | ImportedSpan String -- Module name
+ | ImportedSpan FastString -- Module name
| UnhelpfulSpan FastString -- Just a general indication
-- also used to indicate an empty span
(srcSpanStart a `compare` srcSpanStart b) `thenCmp`
(srcSpanEnd a `compare` srcSpanEnd b)
-noSrcSpan = UnhelpfulSpan FSLIT("<no location info>")
+noSrcSpan = UnhelpfulSpan FSLIT("<no location info>")
+wiredInSrcSpan = UnhelpfulSpan FSLIT("<wired into compiler>")
+importedSrcSpan = ImportedSpan
mkGeneralSrcSpan :: FastString -> SrcSpan
mkGeneralSrcSpan = UnhelpfulSpan
col2 = srcSpanEndCol end
file = srcSpanFile start
-pprDefnLoc :: SrcLoc -> SDoc
+pprDefnLoc :: SrcSpan -> SDoc
-- "defined at ..." or "imported from ..."
pprDefnLoc loc
- | isGoodSrcLoc loc = ptext SLIT("Defined at") <+> ppr loc
- | otherwise = ppr loc
+ | isGoodSrcSpan loc = ptext SLIT("Defined at") <+> ppr loc
+ | otherwise = ppr loc
instance Outputable SrcSpan where
ppr span
char ':', int col
]
-pprUserSpan (ImportedSpan mod) = ptext SLIT("Defined in") <+> text mod
+pprUserSpan (ImportedSpan mod) = ptext SLIT("Defined in") <+> ftext mod
pprUserSpan (UnhelpfulSpan s) = ftext s
\end{code}
name = idName id
uniq = nameUnique name
new_occ = mkLocalOcc uniq (nameOccName name)
- loc = nameSrcLoc name
+ loc = nameSrcSpan name
-- We want to conjure up a name that can't clash with any
-- existing name. So we generate
-- Mod_$L243foo
-- which should save some space.
-- But note that tidyLetBndr puts some of it back.
ty' = tidyType env (idType id)
- id' = mkUserLocal occ' (idUnique id) ty' noSrcLoc
+ id' = mkUserLocal occ' (idUnique id) ty' noSrcSpan
`setIdInfo` vanillaIdInfo
var_env' = extendVarEnv var_env id id'
in
co_kind = substTy subst (mkPredTy eq_pred)
-- make value vars, instantiating types
- mk_id_var uniq fs ty = mkUserLocal (mkVarOccFS fs) uniq (substTy subst ty) noSrcLoc
+ mk_id_var uniq fs ty = mkUserLocal (mkVarOccFS fs) uniq (substTy subst ty) noSrcSpan
id_bndrs = zipWith3 mk_id_var id_uniqs id_fss arg_tys
exprIsConApp_maybe :: CoreExpr -> Maybe (DataCon, [CoreExpr])
hash_x = mkInternalName unboundKey {- doesn't matter much -}
(mkVarOccFS FSLIT("#x"))
- noSrcLoc
+ noSrcSpan
make_row_vars_for_constructor :: (EqnNo, EquationInfo) -> [WarningPat]
make_row_vars_for_constructor (_, EqnInfo { eqn_pats = pats})
| otherwise = mkBreakPointOpId uq mod ix
uq2 <- newUnique
let occName = mkVarOcc "tick"
- let name = mkInternalName uq2 occName noSrcLoc -- use mkSysLocal?
+ let name = mkInternalName uq2 occName noSrcSpan -- use mkSysLocal?
let var = Id.mkLocalId name realWorldStatePrimTy
scrut <-
if opt_Hpc
us <- mkSplitUniqSupply 'b'
let unique = uniqFromSupply us
occname = mkOccName varName userName
- name = mkInternalName unique occname noSrcLoc
+ name = mkInternalName unique occname noSrcSpan
return name
skolemSubst subst = subst `setTvSubstEnv`
listTags unqual modInfo =
[ tagInfo unqual name loc
| name <- GHC.modInfoExports modInfo
- , let loc = nameSrcLoc name
+ , let loc = srcSpanStart (nameSrcSpan name)
, isGoodSrcLoc loc
]
io $ putStrLn "Perhaps no modules are loaded for debugging?"
| otherwise = do -- try parsing it as an identifier
wantNameFromInterpretedModule noCanDo arg1 $ \name -> do
- let loc = GHC.nameSrcLoc name
+ let loc = GHC.srcSpanStart (GHC.nameSrcSpan name)
if GHC.isGoodSrcLoc loc
then findBreakAndSet (GHC.nameModule name) $
findBreakByCoord (Just (GHC.srcLocFile loc))
listModuleLine mod (read arg2)
list2 [arg] = do
wantNameFromInterpretedModule noCanDo arg $ \name -> do
- let loc = GHC.nameSrcLoc name
+ let loc = GHC.srcSpanStart (GHC.nameSrcSpan name)
if GHC.isGoodSrcLoc loc
then do
tickArray <- getTickArray (GHC.nameModule name)
--
-- The strict applications ensure that any buried exceptions get forced
thRdrName ctxt_ns occ (TH.NameG th_ns pkg mod) = (mkOrig $! (mkModule (mk_pkg pkg) (mk_mod mod))) $! (mk_occ (mk_ghc_ns th_ns) occ)
-thRdrName ctxt_ns occ (TH.NameL uniq) = nameRdrName $! (((Name.mkInternalName $! (mk_uniq uniq)) $! (mk_occ ctxt_ns occ)) noSrcLoc)
+thRdrName ctxt_ns occ (TH.NameL uniq) = nameRdrName $! (((Name.mkInternalName $! (mk_uniq uniq)) $! (mk_occ ctxt_ns occ)) noSrcSpan)
thRdrName ctxt_ns occ (TH.NameQ mod) = (mkRdrQual $! (mk_mod mod)) $! (mk_occ ctxt_ns occ)
thRdrName ctxt_ns occ (TH.NameU uniq) = mkRdrUnqual $! (mk_uniq_occ ctxt_ns occ uniq)
thRdrName ctxt_ns occ TH.NameS
let
us = nsUniqs nc
uniq = uniqFromSupply us
- name = mkExternalName uniq mod occ noSrcLoc
+ name = mkExternalName uniq mod occ noSrcSpan
new_cache = extendNameCache cache mod occ name
in
case splitUniqSupply us of { (us',_) ->
%*********************************************************
\begin{code}
-newGlobalBinder :: Module -> OccName -> SrcLoc -> TcRnIf a b Name
+newGlobalBinder :: Module -> OccName -> SrcSpan -> TcRnIf a b Name
-- Used for source code and interface files, to make the
-- Name for a thing, given its Module and OccName
--
allocateGlobalBinder
:: NameCache
- -> Module -> OccName -> SrcLoc
+ -> Module -> OccName -> SrcSpan
-> (NameCache, Name)
allocateGlobalBinder name_supply mod occ loc
= case lookupOrigNameCache (nsNames name_supply) mod occ of
newImplicitBinder base_name mk_sys_occ
= newGlobalBinder (nameModule base_name)
(mk_sys_occ (nameOccName base_name))
- (nameSrcLoc base_name)
+ (nameSrcSpan base_name)
ifaceExportNames :: [IfaceExport] -> TcRnIf gbl lcl [AvailInfo]
ifaceExportNames exports = do
let
us = nsUniqs name_cache
uniq = uniqFromSupply us
- name = mkExternalName uniq mod occ noSrcLoc
+ name = mkExternalName uniq mod occ noSrcSpan
new_cache = extendNameCache (nsNames name_cache) mod occ name
in
case splitUniqSupply us of { (us',_) -> do
newIfaceName :: OccName -> IfL Name
newIfaceName occ
= do { uniq <- newUnique
- ; return $! mkInternalName uniq occ noSrcLoc }
+ ; return $! mkInternalName uniq occ noSrcSpan }
newIfaceNames :: [OccName] -> IfL [Name]
newIfaceNames occs
= do { uniqs <- newUniqueSupply
- ; return [ mkInternalName uniq occ noSrcLoc
+ ; return [ mkInternalName uniq occ noSrcSpan
| (occ,uniq) <- occs `zip` uniqsFromSupply uniqs] }
\end{code}
-- * location
-- imported name, to fix the module correctly in the cache
mk_new_bndr mod occ
- = newGlobalBinder mod occ
- (importedSrcLoc (showSDoc (ppr (moduleName mod))))
+ = newGlobalBinder mod occ (importedSrcSpan (moduleNameFS (moduleName mod)))
-- ToDo: qualify with the package name if necessary
doc = ptext SLIT("Declaration for") <+> ppr (ifName decl)
newExtCoreBndr :: IfaceLetBndr -> IfL Id
newExtCoreBndr (IfLetBndr var ty _) -- Ignoring IdInfo for now
= do { mod <- getIfModule
- ; name <- newGlobalBinder mod (mkVarOccFS var) noSrcLoc
+ ; name <- newGlobalBinder mod (mkVarOccFS var) noSrcSpan
; ty' <- tcIfaceType ty
; return (mkLocalId name ty') }
-- ** Names
Name,
- nameModule, pprParenSymName, nameSrcLoc,
+ nameModule, pprParenSymName, nameSrcSpan,
NamedThing(..),
RdrName(Qual,Unqual),
mkSrcLoc, isGoodSrcLoc,
srcLocFile, srcLocLine, srcLocCol,
SrcSpan,
- mkSrcSpan, srcLocSpan,
+ mkSrcSpan, srcLocSpan, isGoodSrcSpan,
srcSpanStart, srcSpanEnd,
srcSpanFile,
srcSpanStartLine, srcSpanEndLine,
-- _result in scope at any time.
let result_fs = FSLIT("_result")
result_name = mkInternalName (getUnique result_fs)
- (mkVarOccFS result_fs) (srcSpanStart span)
+ (mkVarOccFS result_fs) span
result_id = Id.mkLocalId result_name result_ty
-- for each Id we're about to bind in the local envt:
mkNewId :: OccName -> Id -> IO Id
mkNewId occ id = do
let uniq = idUnique id
- loc = nameSrcLoc (idName id)
+ loc = nameSrcSpan (idName id)
name = mkInternalName uniq occ loc
ty = idType id
new_id = Id.mkGlobalId VanillaGlobal name ty (idInfo id)
import TyCon ( tyConFamInst_maybe )
import Type ( pprTypeApp )
-import GHC ( TyThing(..), SrcLoc )
+import GHC ( TyThing(..), SrcSpan )
import Outputable
-- -----------------------------------------------------------------------------
pprTyThingLoc :: Bool -> TyThing -> SDoc
pprTyThingLoc exts tyThing
= showWithLoc loc (pprTyThing exts tyThing)
- where loc = GHC.nameSrcLoc (GHC.getName tyThing)
+ where loc = GHC.nameSrcSpan (GHC.getName tyThing)
-- | Pretty-prints a 'TyThing'.
pprTyThing :: Bool -> TyThing -> SDoc
pprTyThingInContextLoc :: Bool -> TyThing -> SDoc
pprTyThingInContextLoc exts tyThing
= showWithLoc loc (pprTyThingInContext exts tyThing)
- where loc = GHC.nameSrcLoc (GHC.getName tyThing)
+ where loc = GHC.nameSrcSpan (GHC.getName tyThing)
-- | Pretty-prints a 'TyThing' in context: that is, if the entity
-- is a data constructor, record selector, or class method, then
ppr_bndr :: GHC.NamedThing a => a -> SDoc
ppr_bndr a = GHC.pprParenSymName a
-showWithLoc :: SrcLoc -> SDoc -> SDoc
+showWithLoc :: SrcSpan -> SDoc -> SDoc
showWithLoc loc doc
= hang doc 2 (char '\t' <> comment <+> GHC.pprDefnLoc loc)
-- The tab tries to make them line up a bit
import InstEnv ( Instance, DFunId, instanceDFunId, setInstanceDFunId )
import NewDemand ( isBottomingSig, topSig )
import BasicTypes ( Arity, isNeverActive, isNonRuleLoopBreaker )
-import Name ( Name, getOccName, nameOccName, mkInternalName,
- localiseName, isExternalName, nameSrcLoc,
- isWiredInName, getName
- )
+import Name
import NameSet ( NameSet, elemNameSet )
import IfaceEnv ( allocateGlobalBinder )
import NameEnv ( filterNameEnv, mapNameEnv )
global = isExternalName name
local = not global
internal = not external
- loc = nameSrcLoc name
+ loc = nameSrcSpan name
(occ_env', occ') = tidyOccName occ_env (nameOccName name)
)
import BasicTypes ( Boxity(..), Arity )
import Name ( Name, mkInternalName, mkExternalName )
-import SrcLoc ( noSrcLoc )
+import SrcLoc
import FastString
\end{code}
This *local* name is used by the interactive stuff
\begin{code}
-itName uniq = mkInternalName uniq (mkOccNameFS varName FSLIT("it")) noSrcLoc
+itName uniq = mkInternalName uniq (mkOccNameFS varName FSLIT("it")) noSrcSpan
\end{code}
\begin{code}
-- mkUnboundName makes a place-holder Name; it shouldn't be looked at except possibly
-- during compiler debugging.
mkUnboundName :: RdrName -> Name
-mkUnboundName rdr_name = mkInternalName unboundKey (rdrNameOcc rdr_name) noSrcLoc
+mkUnboundName rdr_name = mkInternalName unboundKey (rdrNameOcc rdr_name) noSrcSpan
isUnboundName :: Name -> Bool
isUnboundName name = name `hasKey` unboundKey
= mkInternalName
breakpointJumpIdKey
(mkOccNameFS varName FSLIT("breakpointJump"))
- noSrcLoc
+ noSrcSpan
breakpointCondJumpName
= mkInternalName
breakpointCondJumpIdKey
(mkOccNameFS varName FSLIT("breakpointCondJump"))
- noSrcLoc
+ noSrcSpan
breakpointAutoJumpName
= mkInternalName
breakpointAutoJumpIdKey
(mkOccNameFS varName FSLIT("breakpointAutoJump"))
- noSrcLoc
+ noSrcSpan
-- PrelTup
fstName = varQual dATA_TUP FSLIT("fst") fstIdKey
clsQual = mk_known_key_name clsName
mk_known_key_name space mod str uniq
- = mkExternalName uniq mod (mkOccNameFS space str) noSrcLoc
+ = mkExternalName uniq mod (mkOccNameFS space str) noSrcSpan
conName :: Module -> FastString -> Unique -> Name
conName mod occ uniq
- = mkExternalName uniq mod (mkOccNameFS dataName occ) noSrcLoc
+ = mkExternalName uniq mod (mkOccNameFS dataName occ) noSrcSpan
methName :: Module -> FastString -> Unique -> Name
methName mod occ uniq
- = mkExternalName uniq mod (mkVarOccFS occ) noSrcLoc
+ = mkExternalName uniq mod (mkVarOccFS occ) noSrcSpan
\end{code}
%************************************************************************
Kind, mkArrowKinds, mkArrowKind,
TyThing(..)
)
-import SrcLoc ( noSrcLoc )
+import SrcLoc
import Unique ( mkAlphaTyVarUnique, pprUnique )
import PrelNames
import FastString ( FastString, mkFastString )
tyVarList :: Kind -> [TyVar]
tyVarList kind = [ mkTyVar (mkInternalName (mkAlphaTyVarUnique u)
(mkTyVarOcc (mkFastString name))
- noSrcLoc) kind
+ noSrcSpan) kind
| u <- [2..],
let name | c <= 'z' = [c]
| otherwise = 't':show u
-- the RdrName, not from the environment. In principle, it'd be fine to
-- have an arbitrary mixture of external core definitions in a single module,
-- (apart from module-initialisation issues, perhaps).
- ; newGlobalBinder rdr_mod rdr_occ (srcSpanStart loc) }
+ ; newGlobalBinder rdr_mod rdr_occ loc }
--TODO, should pass the whole span
| otherwise
(addErrAt loc (badQualBndrErr rdr_name))
-- Binders should not be qualified; if they are, and with a different
-- module name, we we get a confusing "M.T is not in scope" error later
- ; newGlobalBinder this_mod (rdrNameOcc rdr_name) (srcSpanStart loc) }
+ ; newGlobalBinder this_mod (rdrNameOcc rdr_name) loc }
\end{code}
%*********************************************************
-- we don't bother to call newTopSrcBinder first
-- We assume there is no "parent" name
= do { loc <- getSrcSpanM
- ; newGlobalBinder rdr_mod rdr_occ (srcSpanStart loc) }
+ ; newGlobalBinder rdr_mod rdr_occ loc }
| otherwise
= do { mb_gre <- lookupGreLocalRn rdr_name
| otherwise = ASSERT2( isUnqual rdr_name, ppr rdr_name )
-- We only bind unqualified names here
-- lookupRdrEnv doesn't even attempt to look up a qualified RdrName
- mkInternalName uniq (rdrNameOcc rdr_name) (srcSpanStart loc)
+ mkInternalName uniq (rdrNameOcc rdr_name) loc
bindLocatedLocalsRn :: SDoc -- Documentation string for error message
-> [Located RdrName]
import Var ( Var )
import VarEnv
import VarSet
-import Name ( nameOccName, nameSrcLoc )
+import Name
import Rules ( addIdSpecialisations, mkLocalRule, rulesOfBinds )
import OccName ( mkSpecOcc )
import ErrUtils ( dumpIfSet_dyn )
-- a spec_rhs of unlifted type and no args
fn_name = idName fn
- fn_loc = nameSrcLoc fn_name
+ fn_loc = nameSrcSpan fn_name
spec_occ = mkSpecOcc (nameOccName fn_name)
rule_name = mkFastString ("SC:" ++ showSDoc (ppr fn <> int rule_number))
spec_rhs = mkLams spec_lam_args spec_body
UniqSM, initUs_, thenUs, returnUs, getUniqueUs,
getUs, mapUs
)
-import Name ( nameOccName, mkSpecOcc, getSrcLoc )
+import Name
import MkId ( voidArgId, realWorldPrimId )
import FiniteMap
import Maybes ( catMaybes, maybeToBool )
let
-- Give the new Id a similar occurrence name to the old one
name = idName old_id
- new_id = mkUserLocal (mkSpecOcc (nameOccName name)) uniq new_ty (getSrcLoc name)
+ new_id = mkUserLocal (mkSpecOcc (nameOccName name)) uniq new_ty (getSrcSpan name)
in
returnSM new_id
\end{code}
\begin{code}
mkPredName :: Unique -> InstLoc -> PredType -> Name
mkPredName uniq loc pred_ty
- = mkInternalName uniq occ (srcSpanStart (instLocSpan loc))
+ = mkInternalName uniq occ (instLocSpan loc)
where
occ = case pred_ty of
ClassP cls _ -> mkDictOcc (getOccName cls)
meth_id = mkUserLocal (mkMethodOcc (getOccName id)) new_uniq tau loc
inst = Method {tci_id = meth_id, tci_oid = id, tci_tys = tys,
tci_theta = theta, tci_loc = inst_loc}
- loc = srcSpanStart (instLocSpan inst_loc)
+ loc = instLocSpan inst_loc
in
returnM inst
\end{code}
getSrcSpanM `thenM` \ loc ->
let
real_tau = mkPhiTy (tail preds) tau
- meth_id = mkUserLocal (getOccName sel_id) uniq real_tau
- (srcSpanStart loc) --TODO
+ meth_id = mkUserLocal (getOccName sel_id) uniq real_tau loc
in
returnM (Nothing, meth_id)
-- Make the dictionary function.
getSrcSpanM `thenM` \ span ->
getOverlapFlag `thenM` \ overlap_flag ->
- newDFunName clas [inst_ty] (srcSpanStart span) `thenM` \ dfun_name ->
+ newDFunName clas [inst_ty] span `thenM` \ dfun_name ->
let
inst_theta = [mkClassPred clas [mkTyVarTy tv] | tv <- tyvars]
dfun_id = mkDictFunId dfun_name tyvars inst_theta clas [inst_ty]
new_dfun_name clas tycon -- Just a simple wrapper
- = newDFunName clas [mkTyConApp tycon []] (getSrcLoc tycon)
+ = newDFunName clas [mkTyConApp tycon []] (getSrcSpan tycon)
-- The type passed to newDFunName is only used to generate
-- a suitable string; hence the empty type arg list
\end{code}
nest 2 (ptext SLIT("Offending constraint:") <+> ppr pred)]
\end{code}
-
\ No newline at end of file
+
name, like otber top-level names, and hence must be made with newGlobalBinder.
\begin{code}
-newDFunName :: Class -> [Type] -> SrcLoc -> TcM Name
+newDFunName :: Class -> [Type] -> SrcSpan -> TcM Name
newDFunName clas (ty:_) loc
= do { index <- nextDFunIndex
; is_boot <- tcIsHsBoot
newGlobalBinder.
\begin{code}
-newFamInstTyConName :: Name -> SrcLoc -> TcM Name
+newFamInstTyConName :: Name -> SrcSpan -> TcM Name
newFamInstTyConName tc_name loc
= do { index <- nextDFunIndex
; mod <- getModule
newUnique `thenM` \ uniq ->
getModule `thenM` \ mod ->
let
- gnm = mkExternalName uniq mod (mkForeignExportOcc (getOccName nm))
- (srcSpanStart loc)
+ gnm = mkExternalName uniq mod (mkForeignExportOcc (getOccName nm)) loc
id = mkExportedLocalId gnm sig_ty
bind = L loc (VarBind id rhs)
in
\end{code}
\begin{code}
-getSrcSpan = srcLocSpan . getSrcLoc
-\end{code}
-
-\begin{code}
a_RDR = mkVarUnqual FSLIT("a")
b_RDR = mkVarUnqual FSLIT("b")
c_RDR = mkVarUnqual FSLIT("c")
= do { checkTc (isLiftedTypeKind res_kind) (badKindSig kind)
; span <- getSrcSpanM
; us <- newUniqueSupply
- ; let loc = srcSpanStart span
- uniqs = uniqsFromSupply us
- ; return [ mk_tv loc uniq str kind
+ ; let uniqs = uniqsFromSupply us
+ ; return [ mk_tv span uniq str kind
| ((kind, str), uniq) <- arg_kinds `zip` names `zip` uniqs ] }
where
(arg_kinds, res_kind) = splitKindFunTys kind
-- Finally, construct the Core representation of the instance.
-- (This no longer includes the associated types.)
- ; dfun_name <- newDFunName clas inst_tys (srcSpanStart loc)
+ ; dfun_name <- newDFunName clas inst_tys loc
; overlap_flag <- getOverlapFlag
; let dfun = mkDictFunId dfun_name tyvars theta clas inst_tys
ispec = mkLocalInstance dfun overlap_flag
tcSkolSigTyVars info tyvars = [ mkSkolTyVar (tyVarName tv) (tyVarKind tv) info
| tv <- tyvars ]
-tcInstSkolTyVar :: SkolemInfo -> Maybe SrcLoc -> TyVar -> TcM TcTyVar
+tcInstSkolTyVar :: SkolemInfo -> Maybe SrcSpan -> TyVar -> TcM TcTyVar
-- Instantiate the tyvar, using
-- * the occ-name and kind of the supplied tyvar,
-- * the unique from the monad,
= do { uniq <- newUnique
; let old_name = tyVarName tyvar
kind = tyVarKind tyvar
- loc = mb_loc `orElse` getSrcLoc old_name
+ loc = mb_loc `orElse` getSrcSpan old_name
new_name = mkInternalName uniq (nameOccName old_name) loc
; return (mkSkolTyVar new_name kind info) }
-- Get the location from the monad
tcInstSkolTyVars info tyvars
= do { span <- getSrcSpanM
- ; mapM (tcInstSkolTyVar info (Just (srcSpanStart span))) tyvars }
+ ; mapM (tcInstSkolTyVar info (Just span)) tyvars }
tcInstSkolType :: SkolemInfo -> TcType -> TcM ([TcTyVar], TcThetaType, TcType)
-- Instantiate a type with fresh skolem constants
-- See Note [Root-main Id]
; let { root_main_name = mkExternalName rootMainKey rOOT_MAIN
(mkVarOccFS FSLIT("main"))
- (getSrcLoc main_name)
+ (getSrcSpan main_name)
; root_main_id = Id.mkExportedLocalId root_main_name ty
; main_bind = noLoc (VarBind root_main_id main_expr) }
newLocalName :: Name -> TcRnIf gbl lcl Name
newLocalName name -- Make a clone
= do { uniq <- newUnique
- ; return (mkInternalName uniq (nameOccName name) (getSrcLoc name)) }
+ ; return (mkInternalName uniq (nameOccName name) (getSrcSpan name)) }
newSysLocalIds :: FastString -> [TcType] -> TcRnIf gbl lcl [TcId]
newSysLocalIds fs tys
| otherwise -- Otherwise we must generate a binding
= do { uniq <- newUnique
; span <- getSrcSpanM
- ; let name = mkInternalName uniq (mkVarOcc "ic") (srcSpanStart span)
+ ; let name = mkInternalName uniq (mkVarOcc "ic") span
implic_inst = ImplicInst { tci_name = name, tci_reft = reft,
tci_tyvars = all_tvs,
tci_given = givens,
; t_rhs <- tcHsKindedType k_rhs
-- (3) construct representation tycon
- ; rep_tc_name <- newFamInstTyConName tc_name (srcSpanStart loc)
+ ; rep_tc_name <- newFamInstTyConName tc_name loc
; tycon <- buildSynTyCon rep_tc_name t_tvs (SynonymTyCon t_rhs)
(Just (family, t_typats))
; stupid_theta <- tcHsKindedContext k_ctxt
-- (3) construct representation tycon
- ; rep_tc_name <- newFamInstTyConName tc_name (srcSpanStart loc)
+ ; rep_tc_name <- newFamInstTyConName tc_name loc
; tycon <- fixM (\ tycon -> do
{ data_cons <- mappM (addLocM (tcConDecl unbox_strict tycon t_tvs))
k_cons
pprFamInst :: FamInst -> SDoc
pprFamInst famInst
= hang (pprFamInstHdr famInst)
- 2 (ptext SLIT("--") <+> (pprDefnLoc (getSrcLoc famInst)))
+ 2 (ptext SLIT("--") <+> (pprDefnLoc (getSrcSpan famInst)))
pprFamInstHdr :: FamInst -> SDoc
pprFamInstHdr (FamInst {fi_fam = fam, fi_tys = tys, fi_tycon = tycon})
-- Prints the Instance as an instance declaration
pprInstance ispec@(Instance { is_flag = flag })
= hang (pprInstanceHdr ispec)
- 2 (ptext SLIT("--") <+> (pprDefnLoc (getSrcLoc ispec)))
+ 2 (ptext SLIT("--") <+> (pprDefnLoc (getSrcSpan ispec)))
-- * pprInstanceHdr is used in VStudio to populate the ClassView tree
pprInstanceHdr :: Instance -> SDoc