Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data RdrName
- mkRdrUnqual :: OccName -> RdrName
- mkRdrQual :: ModuleName -> OccName -> RdrName
- mkUnqual :: NameSpace -> FastString -> RdrName
- mkVarUnqual :: FastString -> RdrName
- mkQual :: NameSpace -> (FastString, FastString) -> RdrName
- mkOrig :: Module -> OccName -> RdrName
- nameRdrName :: Name -> RdrName
- getRdrName :: NamedThing thing => thing -> RdrName
- rdrNameOcc :: RdrName -> OccName
- rdrNameSpace :: RdrName -> NameSpace
- demoteRdrName :: RdrName -> Maybe RdrName
- isRdrDataCon :: RdrName -> Bool
- isRdrTyVar :: RdrName -> Bool
- isRdrTc :: RdrName -> Bool
- isQual :: RdrName -> Bool
- isQual_maybe :: RdrName -> Maybe (ModuleName, OccName)
- isUnqual :: RdrName -> Bool
- isOrig :: RdrName -> Bool
- isOrig_maybe :: RdrName -> Maybe (Module, OccName)
- isExact :: RdrName -> Bool
- isExact_maybe :: RdrName -> Maybe Name
- isSrcRdrName :: RdrName -> Bool
- isStar :: RdrName -> Bool
- isUniStar :: RdrName -> Bool
- data LocalRdrEnv
- emptyLocalRdrEnv :: LocalRdrEnv
- extendLocalRdrEnv :: LocalRdrEnv -> Name -> LocalRdrEnv
- extendLocalRdrEnvList :: LocalRdrEnv -> [Name] -> LocalRdrEnv
- lookupLocalRdrEnv :: LocalRdrEnv -> RdrName -> Maybe Name
- lookupLocalRdrOcc :: LocalRdrEnv -> OccName -> Maybe Name
- elemLocalRdrEnv :: RdrName -> LocalRdrEnv -> Bool
- inLocalRdrEnvScope :: Name -> LocalRdrEnv -> Bool
- localRdrEnvElts :: LocalRdrEnv -> [Name]
- delLocalRdrEnvList :: LocalRdrEnv -> [OccName] -> LocalRdrEnv
- type GlobalRdrEnv = OccEnv [GlobalRdrElt]
- emptyGlobalRdrEnv :: GlobalRdrEnv
- mkGlobalRdrEnv :: [GlobalRdrElt] -> GlobalRdrEnv
- plusGlobalRdrEnv :: GlobalRdrEnv -> GlobalRdrEnv -> GlobalRdrEnv
- lookupGlobalRdrEnv :: GlobalRdrEnv -> OccName -> [GlobalRdrElt]
- extendGlobalRdrEnv :: GlobalRdrEnv -> GlobalRdrElt -> GlobalRdrEnv
- greOccName :: GlobalRdrElt -> OccName
- shadowNames :: GlobalRdrEnv -> [Name] -> GlobalRdrEnv
- pprGlobalRdrEnv :: Bool -> GlobalRdrEnv -> SDoc
- globalRdrEnvElts :: GlobalRdrEnv -> [GlobalRdrElt]
- lookupGRE_RdrName :: RdrName -> GlobalRdrEnv -> [GlobalRdrElt]
- lookupGRE_Name :: GlobalRdrEnv -> Name -> Maybe GlobalRdrElt
- lookupGRE_FieldLabel :: GlobalRdrEnv -> FieldLabel -> Maybe GlobalRdrElt
- getGRE_NameQualifier_maybes :: GlobalRdrEnv -> Name -> [Maybe [ModuleName]]
- transformGREs :: (GlobalRdrElt -> GlobalRdrElt) -> [OccName] -> GlobalRdrEnv -> GlobalRdrEnv
- pickGREs :: RdrName -> [GlobalRdrElt] -> [GlobalRdrElt]
- pickGREsModExp :: ModuleName -> [GlobalRdrElt] -> [(GlobalRdrElt, GlobalRdrElt)]
- gresFromAvails :: Maybe ImportSpec -> [AvailInfo] -> [GlobalRdrElt]
- gresFromAvail :: (Name -> Maybe ImportSpec) -> AvailInfo -> [GlobalRdrElt]
- localGREsFromAvail :: AvailInfo -> [GlobalRdrElt]
- availFromGRE :: GlobalRdrElt -> AvailInfo
- greUsedRdrName :: GlobalRdrElt -> RdrName
- greRdrNames :: GlobalRdrElt -> [RdrName]
- greSrcSpan :: GlobalRdrElt -> SrcSpan
- greQualModName :: GlobalRdrElt -> ModuleName
- gresToAvailInfo :: [GlobalRdrElt] -> [AvailInfo]
- data GlobalRdrElt = GRE {}
- isLocalGRE :: GlobalRdrElt -> Bool
- isRecFldGRE :: GlobalRdrElt -> Bool
- greLabel :: GlobalRdrElt -> Maybe FieldLabelString
- unQualOK :: GlobalRdrElt -> Bool
- qualSpecOK :: ModuleName -> ImportSpec -> Bool
- unQualSpecOK :: ImportSpec -> Bool
- pprNameProvenance :: GlobalRdrElt -> SDoc
- data Parent
- data ImportSpec = ImpSpec {}
- data ImpDeclSpec = ImpDeclSpec {
- is_mod :: ModuleName
- is_as :: ModuleName
- is_qual :: Bool
- is_dloc :: SrcSpan
- data ImpItemSpec
- importSpecLoc :: ImportSpec -> SrcSpan
- importSpecModule :: ImportSpec -> ModuleName
- isExplicitItem :: ImpItemSpec -> Bool
- bestImport :: [ImportSpec] -> ImportSpec
The main type
Reader Name
Do not use the data constructors of RdrName directly: prefer the family
of functions that creates them, such as mkRdrUnqual
- Note: A Located RdrName will only have API Annotations if it is a compound one, e.g.
`bar` ( ~ )
AnnKeywordId
:AnnType
,AnnOpen
'('
or'['
or'[:'
,AnnClose
')'
or']'
or':]'
,,AnnBackquote
'`'
,AnnVal
,AnnTildehsh
,AnnTilde
,
Unqual OccName | Unqualified name Used for ordinary, unqualified occurrences, e.g. |
Qual ModuleName OccName | Qualified name A qualified name written by the user in
source code. The module isn't necessarily
the module where the thing is defined;
just the one from which it is imported.
Examples are |
Orig Module OccName | Original name An original name; the module is the defining module.
This is used when GHC generates code that will be fed
into the renamer (e.g. from deriving clauses), but where
we want to say "Use Prelude.map dammit". One of these
can be created with |
Exact Name | Exact name We know exactly the
Such a |
Instances
Eq RdrName Source # | |
Data RdrName Source # | |
Defined in RdrName gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> RdrName -> c RdrName Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c RdrName Source # toConstr :: RdrName -> Constr Source # dataTypeOf :: RdrName -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c RdrName) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RdrName) Source # gmapT :: (forall b. Data b => b -> b) -> RdrName -> RdrName Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> RdrName -> r Source # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> RdrName -> r Source # gmapQ :: (forall d. Data d => d -> u) -> RdrName -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> RdrName -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> RdrName -> m RdrName Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> RdrName -> m RdrName Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> RdrName -> m RdrName Source # | |
Ord RdrName Source # | |
OutputableBndr RdrName Source # | |
Outputable RdrName Source # | |
HasOccName RdrName Source # | |
Construction
mkRdrUnqual :: OccName -> RdrName Source #
mkVarUnqual :: FastString -> RdrName Source #
mkQual :: NameSpace -> (FastString, FastString) -> RdrName Source #
Make a qualified RdrName
in the given namespace and where the ModuleName
and
the OccName
are taken from the first and second elements of the tuple respectively
nameRdrName :: Name -> RdrName Source #
getRdrName :: NamedThing thing => thing -> RdrName Source #
Destruction
rdrNameOcc :: RdrName -> OccName Source #
rdrNameSpace :: RdrName -> NameSpace Source #
isRdrDataCon :: RdrName -> Bool Source #
isRdrTyVar :: RdrName -> Bool Source #
isQual_maybe :: RdrName -> Maybe (ModuleName, OccName) Source #
isSrcRdrName :: RdrName -> Bool Source #
Local mapping of RdrName
to Name
data LocalRdrEnv Source #
Local Reader Environment
This environment is used to store local bindings
(let
, where
, lambda, case
).
It is keyed by OccName, because we never use it for qualified names
We keep the current mapping, *and* the set of all Names in scope
Reason: see Note [Splicing Exact names] in RnEnv
Instances
Outputable LocalRdrEnv Source # | |
extendLocalRdrEnv :: LocalRdrEnv -> Name -> LocalRdrEnv Source #
extendLocalRdrEnvList :: LocalRdrEnv -> [Name] -> LocalRdrEnv Source #
lookupLocalRdrEnv :: LocalRdrEnv -> RdrName -> Maybe Name Source #
lookupLocalRdrOcc :: LocalRdrEnv -> OccName -> Maybe Name Source #
elemLocalRdrEnv :: RdrName -> LocalRdrEnv -> Bool Source #
inLocalRdrEnvScope :: Name -> LocalRdrEnv -> Bool Source #
localRdrEnvElts :: LocalRdrEnv -> [Name] Source #
delLocalRdrEnvList :: LocalRdrEnv -> [OccName] -> LocalRdrEnv Source #
Global mapping of RdrName
to GlobalRdrElt
s
type GlobalRdrEnv = OccEnv [GlobalRdrElt] Source #
Global Reader Environment
Keyed by OccName
; when looking up a qualified name
we look up the OccName
part, and then check the Provenance
to see if the appropriate qualification is valid. This
saves routinely doubling the size of the env by adding both
qualified and unqualified names to the domain.
The list in the codomain is required because there may be name clashes These only get reported on lookup, not on construction
INVARIANT 1: All the members of the list have distinct
gre_name
fields; that is, no duplicate Names
INVARIANT 2: Imported provenance => Name is an ExternalName However LocalDefs can have an InternalName. This happens only when type-checking a [d| ... |] Template Haskell quotation; see this note in RnNames Note [Top-level Names in Template Haskell decl quotes]
INVARIANT 3: If the GlobalRdrEnv maps [occ -> gre], then greOccName gre = occ
NB: greOccName gre is usually the same as nameOccName (gre_name gre), but not always in the case of record seectors; see greOccName
mkGlobalRdrEnv :: [GlobalRdrElt] -> GlobalRdrEnv Source #
lookupGlobalRdrEnv :: GlobalRdrEnv -> OccName -> [GlobalRdrElt] Source #
greOccName :: GlobalRdrElt -> OccName Source #
shadowNames :: GlobalRdrEnv -> [Name] -> GlobalRdrEnv Source #
pprGlobalRdrEnv :: Bool -> GlobalRdrEnv -> SDoc Source #
globalRdrEnvElts :: GlobalRdrEnv -> [GlobalRdrElt] Source #
lookupGRE_RdrName :: RdrName -> GlobalRdrEnv -> [GlobalRdrElt] Source #
lookupGRE_Name :: GlobalRdrEnv -> Name -> Maybe GlobalRdrElt Source #
lookupGRE_FieldLabel :: GlobalRdrEnv -> FieldLabel -> Maybe GlobalRdrElt Source #
Look for a particular record field selector in the environment, where the selector name and field label may be different: the GlobalRdrEnv is keyed on the label. See Note [Parents for record fields] for why this happens.
getGRE_NameQualifier_maybes :: GlobalRdrEnv -> Name -> [Maybe [ModuleName]] Source #
transformGREs :: (GlobalRdrElt -> GlobalRdrElt) -> [OccName] -> GlobalRdrEnv -> GlobalRdrEnv Source #
Apply a transformation function to the GREs for these OccNames
pickGREs :: RdrName -> [GlobalRdrElt] -> [GlobalRdrElt] Source #
Takes a list of GREs which have the right OccName x
Pick those GREs that are are in scope
* Qualified, as x
if want_qual is Qual M _
* Unqualified, as x
if want_unqual is Unqual _
Return each such GRE, with its ImportSpecs filtered, to reflect how it is in scope qualified or unqualified respectively. See Note [GRE filtering]
pickGREsModExp :: ModuleName -> [GlobalRdrElt] -> [(GlobalRdrElt, GlobalRdrElt)] Source #
Pick GREs that are in scope *both* qualified *and* unqualified Return each GRE that is, as a pair (qual_gre, unqual_gre) These two GREs are the original GRE with imports filtered to express how it is in scope qualified an unqualified respectively
Used only for the 'module M' item in export list; see RnNames.exports_from_avail
GlobalRdrElts
gresFromAvails :: Maybe ImportSpec -> [AvailInfo] -> [GlobalRdrElt] Source #
make a GlobalRdrEnv
where all the elements point to the same
Provenance (useful for "hiding" imports, or imports with no details).
gresFromAvail :: (Name -> Maybe ImportSpec) -> AvailInfo -> [GlobalRdrElt] Source #
localGREsFromAvail :: AvailInfo -> [GlobalRdrElt] Source #
availFromGRE :: GlobalRdrElt -> AvailInfo Source #
greUsedRdrName :: GlobalRdrElt -> RdrName Source #
greRdrNames :: GlobalRdrElt -> [RdrName] Source #
greSrcSpan :: GlobalRdrElt -> SrcSpan Source #
gresToAvailInfo :: [GlobalRdrElt] -> [AvailInfo] Source #
Takes a list of distinct GREs and folds them
into AvailInfos. This is more efficient than mapping each individual
GRE to an AvailInfo and the folding using plusAvail
but needs the
uniqueness assumption.
Global RdrName
mapping elements: GlobalRdrElt
, Provenance
, ImportSpec
data GlobalRdrElt Source #
Global Reader Element
An element of the GlobalRdrEnv
Instances
Eq GlobalRdrElt Source # | |
Defined in RdrName (==) :: GlobalRdrElt -> GlobalRdrElt -> Bool # (/=) :: GlobalRdrElt -> GlobalRdrElt -> Bool # | |
Data GlobalRdrElt Source # | |
Defined in RdrName gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> GlobalRdrElt -> c GlobalRdrElt Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c GlobalRdrElt Source # toConstr :: GlobalRdrElt -> Constr Source # dataTypeOf :: GlobalRdrElt -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c GlobalRdrElt) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c GlobalRdrElt) Source # gmapT :: (forall b. Data b => b -> b) -> GlobalRdrElt -> GlobalRdrElt Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> GlobalRdrElt -> r Source # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> GlobalRdrElt -> r Source # gmapQ :: (forall d. Data d => d -> u) -> GlobalRdrElt -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> GlobalRdrElt -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> GlobalRdrElt -> m GlobalRdrElt Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> GlobalRdrElt -> m GlobalRdrElt Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> GlobalRdrElt -> m GlobalRdrElt Source # | |
Outputable GlobalRdrElt Source # | |
isLocalGRE :: GlobalRdrElt -> Bool Source #
isRecFldGRE :: GlobalRdrElt -> Bool Source #
unQualOK :: GlobalRdrElt -> Bool Source #
Test if an unqualified version of this thing would be in scope
qualSpecOK :: ModuleName -> ImportSpec -> Bool Source #
Is in scope qualified with the given module?
unQualSpecOK :: ImportSpec -> Bool Source #
Is in scope unqualified?
pprNameProvenance :: GlobalRdrElt -> SDoc Source #
Print out one place where the name was define/imported (With -dppr-debug, print them all)
The children of a Name are the things that are abbreviated by the ".." notation in export lists. See Note [Parents]
NoParent | |
ParentIs | |
FldParent | See Note [Parents for record fields] |
|
Instances
Eq Parent Source # | |
Data Parent Source # | |
Defined in RdrName gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Parent -> c Parent Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Parent Source # toConstr :: Parent -> Constr Source # dataTypeOf :: Parent -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Parent) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Parent) Source # gmapT :: (forall b. Data b => b -> b) -> Parent -> Parent Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Parent -> r Source # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Parent -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Parent -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Parent -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Parent -> m Parent Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Parent -> m Parent Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Parent -> m Parent Source # | |
Outputable Parent Source # | |
data ImportSpec Source #
Import Specification
The ImportSpec
of something says how it came to be imported
It's quite elaborate so that we can give accurate unused-name warnings.
Instances
data ImpDeclSpec Source #
Import Declaration Specification
Describes a particular import declaration and is
shared among all the Provenance
s for that decl
ImpDeclSpec | |
|
Instances
data ImpItemSpec Source #
Import Item Specification
Describes import info a particular Name
ImpAll | The import had no import list, or had a hiding list |
ImpSome | The import had an import list.
The import C( T(..) ) Here the constructors of |
|
Instances
importSpecLoc :: ImportSpec -> SrcSpan Source #
isExplicitItem :: ImpItemSpec -> Bool Source #
bestImport :: [ImportSpec] -> ImportSpec Source #