GHC.Types.Name.Reader

ghc-lib-parser-9.10.1.20250103: The GHC API, decoupled from GHC versions

Safe Haskell | Ignore
Language | GHC2021

GHC.Types.Name.Reader

Contents

- The main type
  - Construction
  - Destruction
- Local mapping of `RdrName` to `Name`
- Global mapping of `RdrName` to `GlobalRdrElt`s
  - Looking up `GlobalRdrElt`s
- GlobalRdrElts
  - Global `RdrName` mapping elements: `GlobalRdrElt`, `Provenance`, `ImportSpec`
  - Shadowing
  - Information attached to a `GlobalRdrElt`
  - Parent information
- Utils

Description

GHC uses several kinds of name internally:

- `OccName`: see GHC.Types.Name.Occurrence
- `RdrName` is the type of names that come directly from the parser. They have not yet had their scoping and binding resolved by the renamer and can be thought of to a first approximation as an `OccName` with an optional module qualifier
- `Name`: see GHC.Types.Name
- `Id`: see GHC.Types.Id
- `Var`: see GHC.Types.Var

Synopsis

- data RdrName
  - = Unqual OccName
  - | Qual ModuleName OccName
  - | Orig Module OccName
  - | Exact Name
- 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
- demoteRdrNameTv :: RdrName -> Maybe RdrName
- promoteRdrName :: 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
- 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]
- minusLocalRdrEnv :: LocalRdrEnv -> OccEnv a -> LocalRdrEnv
- minusLocalRdrEnvList :: LocalRdrEnv -> [OccName] -> LocalRdrEnv
- type GlobalRdrEnvX info = OccEnv [GlobalRdrEltX info]
- type GlobalRdrEnv = GlobalRdrEnvX GREInfo
- type IfGlobalRdrEnv = GlobalRdrEnvX ()
- emptyGlobalRdrEnv :: GlobalRdrEnvX info
- mkGlobalRdrEnv :: [GlobalRdrElt] -> GlobalRdrEnv
- plusGlobalRdrEnv :: GlobalRdrEnv -> GlobalRdrEnv -> GlobalRdrEnv
- extendGlobalRdrEnv :: GlobalRdrEnv -> GlobalRdrElt -> GlobalRdrEnv
- greOccName :: GlobalRdrEltX info -> OccName
- pprGlobalRdrEnv :: Bool -> GlobalRdrEnv -> SDoc
- globalRdrEnvElts :: GlobalRdrEnvX info -> [GlobalRdrEltX info]
- data FieldsOrSelectors
  - = WantNormal
  - | WantBoth
  - | WantField
- filterFieldGREs :: FieldsOrSelectors -> [GlobalRdrElt] -> [GlobalRdrElt]
- allowGRE :: FieldsOrSelectors -> GlobalRdrElt -> Bool
- data LookupGRE info where
  - LookupOccName :: forall info. OccName -> WhichGREs info -> LookupGRE info
  - LookupRdrName :: forall info. RdrName -> WhichGREs info -> LookupGRE info
  - LookupExactName :: forall info. {..} -> LookupGRE info
  - LookupChildren :: forall info. OccName -> LookupChild -> LookupGRE info
- lookupGRE :: GlobalRdrEnvX info -> LookupGRE info -> [GlobalRdrEltX info]
- data WhichGREs info where
  - SameNameSpace :: forall info. WhichGREs info
  - RelevantGREs :: {..} -> WhichGREs GREInfo
  - pattern AllRelevantGREs :: WhichGREs GREInfo
  - pattern RelevantGREsFOS :: FieldsOrSelectors -> WhichGREs GREInfo
- greIsRelevant :: WhichGREs GREInfo -> NameSpace -> GlobalRdrElt -> Bool
- data LookupChild = LookupChild {
  - wantedParent :: Name
  - lookupDataConFirst :: Bool
  - prioritiseParent :: Bool
  }
- lookupGRE_Name :: Outputable info => GlobalRdrEnvX info -> Name -> Maybe (GlobalRdrEltX info)
- lookupGRE_FieldLabel :: GlobalRdrEnv -> FieldLabel -> Maybe FieldGlobalRdrElt
- getGRE_NameQualifier_maybes :: GlobalRdrEnv -> Name -> [Maybe [ModuleName]]
- transformGREs :: (GlobalRdrElt -> GlobalRdrElt) -> [OccName] -> GlobalRdrEnv -> GlobalRdrEnv
- pickGREs :: RdrName -> [GlobalRdrEltX info] -> [GlobalRdrEltX info]
- pickGREsModExp :: ModuleName -> [GlobalRdrEltX info] -> [(GlobalRdrEltX info, GlobalRdrEltX info)]
- availFromGRE :: GlobalRdrEltX info -> AvailInfo
- greRdrNames :: GlobalRdrEltX info -> [RdrName]
- greSrcSpan :: Outputable info => GlobalRdrEltX info -> SrcSpan
- greQualModName :: Outputable info => GlobalRdrEltX info -> ModuleName
- gresToAvailInfo :: [GlobalRdrEltX info] -> [AvailInfo]
- greDefinitionModule :: GlobalRdrEltX info -> Maybe Module
- greDefinitionSrcSpan :: GlobalRdrEltX info -> SrcSpan
- greFieldLabel_maybe :: GlobalRdrElt -> Maybe FieldLabel
- data GlobalRdrEltX info = GRE {
  - gre_name :: !Name
  - gre_par :: !Parent
  - gre_lcl :: !Bool
  - gre_imp :: !(Bag ImportSpec)
  - gre_info :: info
  }
- type GlobalRdrElt = GlobalRdrEltX GREInfo
- type IfGlobalRdrElt = GlobalRdrEltX ()
- type FieldGlobalRdrElt = GlobalRdrElt
- greName :: GlobalRdrEltX info -> Name
- greNameSpace :: GlobalRdrEltX info -> NameSpace
- greParent :: GlobalRdrEltX info -> Parent
- greInfo :: GlobalRdrElt -> GREInfo
- plusGRE :: GlobalRdrElt -> GlobalRdrElt -> GlobalRdrElt
- insertGRE :: GlobalRdrElt -> [GlobalRdrElt] -> [GlobalRdrElt]
- forceGlobalRdrEnv :: GlobalRdrEnvX info -> IfGlobalRdrEnv
- hydrateGlobalRdrEnv :: (Name -> IO info) -> GlobalRdrEnvX noInfo -> GlobalRdrEnvX info
- isLocalGRE :: GlobalRdrEltX info -> Bool
- isImportedGRE :: GlobalRdrEltX info -> Bool
- isRecFldGRE :: GlobalRdrEltX info -> Bool
- fieldGREInfo :: HasDebugCallStack => FieldGlobalRdrElt -> RecFieldInfo
- isDuplicateRecFldGRE :: GlobalRdrElt -> Bool
- isNoFieldSelectorGRE :: GlobalRdrElt -> Bool
- isFieldSelectorGRE :: GlobalRdrElt -> Bool
- unQualOK :: GlobalRdrEltX info -> Bool
- qualSpecOK :: ModuleName -> ImportSpec -> Bool
- unQualSpecOK :: ImportSpec -> Bool
- pprNameProvenance :: GlobalRdrEltX info -> SDoc
- mkGRE :: (Name -> Maybe ImportSpec) -> GREInfo -> Parent -> Name -> GlobalRdrElt
- mkExactGRE :: Name -> GREInfo -> GlobalRdrElt
- mkLocalGRE :: GREInfo -> Parent -> Name -> GlobalRdrElt
- mkLocalVanillaGRE :: Parent -> Name -> GlobalRdrElt
- mkLocalTyConGRE :: TyConFlavour Name -> Name -> GlobalRdrElt
- mkLocalConLikeGRE :: Parent -> (ConLikeName, ConInfo) -> GlobalRdrElt
- mkLocalFieldGREs :: Parent -> [(ConLikeName, ConInfo)] -> [GlobalRdrElt]
- gresToNameSet :: [GlobalRdrEltX info] -> NameSet
- greClashesWith :: GlobalRdrElt -> GlobalRdrElt -> Bool
- shadowNames :: Bool -> GlobalRdrEnv -> GlobalRdrEnv -> GlobalRdrEnv
- data ConLikeName
  - = DataConName {
    - conLikeName_Name :: !Name
    }
  - | PatSynName {
    - conLikeName_Name :: !Name
    }
- data GREInfo
  - = Vanilla
  - | UnboundGRE
  - | IAmTyCon !(TyConFlavour Name)
  - | IAmConLike !ConInfo
  - | IAmRecField !RecFieldInfo
- data RecFieldInfo = RecFieldInfo {
  - recFieldLabel :: !FieldLabel
  - recFieldCons :: !(UniqSet ConLikeName)
  }
- plusGREInfo :: GREInfo -> GREInfo -> GREInfo
- recFieldConLike_maybe :: HasDebugCallStack => GlobalRdrElt -> Maybe ConInfo
- recFieldInfo_maybe :: HasDebugCallStack => GlobalRdrElt -> Maybe RecFieldInfo
- fieldGRE_maybe :: GlobalRdrElt -> Maybe FieldGlobalRdrElt
- fieldGRELabel :: HasDebugCallStack => FieldGlobalRdrElt -> FieldLabel
- data Parent
  - = NoParent
  - | ParentIs {
    - par_is :: !Name
    }
- greParent_maybe :: GlobalRdrEltX info -> Maybe Name
- mkParent :: Name -> AvailInfo -> Parent
- availParent :: AvailInfo -> Parent
- data ImportSpec = ImpSpec {
  - is_decl :: !ImpDeclSpec
  - is_item :: !ImpItemSpec
  }
- data ImpDeclSpec = ImpDeclSpec {
  - is_mod :: !Module
  - is_as :: !ModuleName
  - is_qual :: !Bool
  - is_dloc :: !SrcSpan
  }
- data ImpItemSpec
  - = ImpAll
  - | ImpSome {
    - is_explicit :: !Bool
    - is_iloc :: !SrcSpan
    }
- importSpecLoc :: ImportSpec -> SrcSpan
- importSpecModule :: ImportSpec -> ModuleName
- isExplicitItem :: ImpItemSpec -> Bool
- bestImport :: NonEmpty ImportSpec -> ImportSpec
- opIsAt :: RdrName -> Bool

# The main type

data RdrName #

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` `AnnTilde`,

Constructors

Unqual OccName | Unqualified name Used for ordinary, unqualified occurrences, e.g. `x`, `y` or `Foo`. Create such a `RdrName` with `mkRdrUnqual`
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 `Bar.x`, `Bar.y` or `Bar.Foo`. Create such a `RdrName` with `mkRdrQual`
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 `mkOrig`
Exact Name | Exact name We know exactly the `Name`. This is used: When the parser parses built-in syntax like `[]` and `(,)`, but wants a `RdrName` from it By Template Haskell, when TH has generated a unique name Such a `RdrName` can be created by using `getRdrName` on a `Name`

#### Instances

Instances details

Data RdrName # |
Instance details Defined in GHC.Types.Name.Reader Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> RdrName -> c RdrName # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c RdrName # toConstr :: RdrName -> Constr # dataTypeOf :: RdrName -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c RdrName) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RdrName) # gmapT :: (forall b. Data b => b -> b) -> RdrName -> RdrName # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> RdrName -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> RdrName -> r # gmapQ :: (forall d. Data d => d -> u) -> RdrName -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> RdrName -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> RdrName -> m RdrName # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> RdrName -> m RdrName # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> RdrName -> m RdrName #
DisambInfixOp RdrName # |
Instance details Defined in GHC.Parser.PostProcess Methods mkHsVarOpPV :: LocatedN RdrName -> PV (LocatedN RdrName) # mkHsConOpPV :: LocatedN RdrName -> PV (LocatedN RdrName) # mkHsInfixHolePV :: LocatedN (HsExpr GhcPs) -> PV (LocatedN RdrName) #
HasOccName RdrName # |
Instance details Defined in GHC.Types.Name.Reader Methods occName :: RdrName -> OccName #
Outputable RdrName # |
Instance details Defined in GHC.Types.Name.Reader Methods ppr :: RdrName -> SDoc #
OutputableBndr RdrName # |
Instance details Defined in GHC.Types.Name.Reader Methods pprBndr :: BindingSite -> RdrName -> SDoc # pprPrefixOcc :: RdrName -> SDoc # pprInfixOcc :: RdrName -> SDoc # bndrIsJoin_maybe :: RdrName -> JoinPointHood #
Eq RdrName # |
Instance details Defined in GHC.Types.Name.Reader Methods (==) :: RdrName -> RdrName -> Bool # (/=) :: RdrName -> RdrName -> Bool #
Ord RdrName # |
Instance details Defined in GHC.Types.Name.Reader Methods compare :: RdrName -> RdrName -> Ordering # (<) :: RdrName -> RdrName -> Bool # (<=) :: RdrName -> RdrName -> Bool # (>) :: RdrName -> RdrName -> Bool # (>=) :: RdrName -> RdrName -> Bool # max :: RdrName -> RdrName -> RdrName # min :: RdrName -> RdrName -> RdrName #
type Anno RdrName # |
Instance details Defined in GHC.Hs.Extension type Anno RdrName = SrcSpanAnnN

## Construction

mkRdrUnqual :: OccName -> RdrName #

mkRdrQual :: ModuleName -> OccName -> RdrName #

mkUnqual :: NameSpace -> FastString -> RdrName #

mkVarUnqual :: FastString -> RdrName #

mkQual :: NameSpace -> (FastString, FastString) -> RdrName #

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

mkOrig :: Module -> OccName -> RdrName #

nameRdrName :: Name -> RdrName #

getRdrName :: NamedThing thing => thing -> RdrName #

## Destruction

rdrNameOcc :: RdrName -> OccName #

rdrNameSpace :: RdrName -> NameSpace #

demoteRdrName :: RdrName -> Maybe RdrName #

demoteRdrNameTv :: RdrName -> Maybe RdrName #

promoteRdrName :: 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 #

# Local mapping of `RdrName` to `Name`

data LocalRdrEnv #

Local Reader Environment See Note [LocalRdrEnv]

#### Instances

Instances details

Outputable LocalRdrEnv # |
Instance details Defined in GHC.Types.Name.Reader Methods ppr :: LocalRdrEnv -> SDoc #

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] #

minusLocalRdrEnv :: LocalRdrEnv -> OccEnv a -> LocalRdrEnv #

minusLocalRdrEnvList :: LocalRdrEnv -> [OccName] -> LocalRdrEnv #

# Global mapping of `RdrName` to `GlobalRdrElt`s

type GlobalRdrEnvX info = OccEnv [GlobalRdrEltX info] #

Parametrises `GlobalRdrEnv` over the presence or absence of `GREInfo`.

See Note [IfGlobalRdrEnv].

type GlobalRdrEnv = GlobalRdrEnvX GREInfo #

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 GHC.Rename.Names Note [Top-level Names in Template Haskell decl quotes]

INVARIANT 3: If the GlobalRdrEnv maps [occ -> gre], then greOccName gre = occ

type IfGlobalRdrEnv = GlobalRdrEnvX () #

A `GlobalRdrEnv` in which the `GlobalRdrElt`s don't have any `GREInfo` attached to them. This is useful to avoid space leaks, see Note [IfGlobalRdrEnv].

emptyGlobalRdrEnv :: GlobalRdrEnvX info #

mkGlobalRdrEnv :: [GlobalRdrElt] -> GlobalRdrEnv #

plusGlobalRdrEnv :: GlobalRdrEnv -> GlobalRdrEnv -> GlobalRdrEnv #

extendGlobalRdrEnv :: GlobalRdrEnv -> GlobalRdrElt -> GlobalRdrEnv #

greOccName :: GlobalRdrEltX info -> OccName #

pprGlobalRdrEnv :: Bool -> GlobalRdrEnv -> SDoc #

globalRdrEnvElts :: GlobalRdrEnvX info -> [GlobalRdrEltX info] #

## Looking up `GlobalRdrElt`s

data FieldsOrSelectors #

When looking up GREs, we may or may not want to include fields that were defined in modules with `NoFieldSelectors` enabled. See Note [NoFieldSelectors].

Constructors

WantNormal | Include normal names, and fields with selectors, but ignore fields without selectors.
WantBoth | Include normal names and all fields (regardless of whether they have selectors).
WantField | Include only fields, with or without selectors, ignoring any non-fields in scope.

#### Instances

Instances details

Show FieldsOrSelectors # |
Instance details Defined in GHC.Types.Name.Reader Methods showsPrec :: Int -> FieldsOrSelectors -> ShowS # show :: FieldsOrSelectors -> String # showList :: [FieldsOrSelectors] -> ShowS #
Eq FieldsOrSelectors # |
Instance details Defined in GHC.Types.Name.Reader Methods (==) :: FieldsOrSelectors -> FieldsOrSelectors -> Bool # (/=) :: FieldsOrSelectors -> FieldsOrSelectors -> Bool #

filterFieldGREs :: FieldsOrSelectors -> [GlobalRdrElt] -> [GlobalRdrElt] #

allowGRE :: FieldsOrSelectors -> GlobalRdrElt -> Bool #

data LookupGRE info where #

What should we look up in a `GlobalRdrEnv`? Should we only look up names with the exact same `OccName`, or do we allow different `NameSpace`s?

Depending on the answer, we might need more or less information from the `GlobalRdrEnv`, e.g. if we want to include matching record fields we need to know if the corresponding record fields define field selectors, for which we need to consult the `GREInfo`. This is why this datatype is a GADT.

See Note [IfGlobalRdrEnv].

Constructors

LookupOccName | Look for this specific `OccName`, with the exact same `NameSpace`, in the `GlobalRdrEnv`.
Fields :: forall info. OccName the `OccName` to look up -> WhichGREs info information about other relevant `NameSpace`s -> LookupGRE info
LookupRdrName | Look up the `OccName` of this `RdrName` in the `GlobalRdrEnv`, filtering out those whose qualification matches that of the `RdrName`. Lookup returns an empty result for `Exact` or `Orig` `RdrName`s.
Fields :: forall info. RdrName the `RdrName` to look up -> WhichGREs info information about other relevant `NameSpace`s -> LookupGRE info
LookupExactName | Look for `GRE`s with the same unique as the given `Name` in the `GlobalRdrEnv`.
Fields :: forall info. { lookupExactName :: Name the `Name` to look up , lookInAllNameSpaces :: Bool whether to look in *all* `NameSpace`s, or just in the `NameSpace` of the `Name` See Note [Template Haskell ambiguity] } -> LookupGRE info
LookupChildren | Look up children `GlobalRdrElt`s with a given `Parent`.
Fields :: forall info. OccName the `OccName` to look up -> LookupChild information to decide which `GlobalRdrElt`s are valid children after looking up -> LookupGRE info

lookupGRE :: GlobalRdrEnvX info -> LookupGRE info -> [GlobalRdrEltX info] #

Look something up in the Global Reader Environment.

The `LookupGRE` argument specifies what to look up, and in particular whether there should there be any lee-way if the `NameSpace`s don't exactly match.

data WhichGREs info where #

How should we look up in a `GlobalRdrEnv`? Which `NameSpace`s are considered relevant for a given lookup?

Constructors

SameNameSpace :: forall info. WhichGREs info | Only consider `GlobalRdrElt`s with the exact `NameSpace` we look up.
RelevantGREs | Allow `GlobalRdrElt`s with different `NameSpace`s, e.g. allow looking up record fields from the variable `NameSpace`, or looking up a `TyCon` from the data constructor `NameSpace`.
Fields :: { includeFieldSelectors :: !FieldsOrSelectors how should we handle looking up variables? should we include record fields defined with `-XNoFieldSelectors`? should we include non-fields? See Note [NoFieldSelectors]. , lookupVariablesForFields :: !Bool when looking up a record field, should we also look up plain variables? , lookupTyConsAsWell :: !Bool when looking up a variable, field or data constructor, should we also try the type constructor `NameSpace`? } -> WhichGREs GREInfo

Bundled Patterns

pattern AllRelevantGREs :: WhichGREs GREInfo | Look up as many possibly relevant `GlobalRdrElt`s as possible.
pattern RelevantGREsFOS :: FieldsOrSelectors -> WhichGREs GREInfo | Look up relevant GREs, taking into account the interaction between the variable and field `NameSpace`s as determined by the `FieldsOrSelector` argument.

#### Instances

Instances details

Outputable (WhichGREs info) # |
Instance details Defined in GHC.Types.Name.Reader Methods ppr :: WhichGREs info -> SDoc #

greIsRelevant #

Arguments

:: WhichGREs GREInfo | specification of which `GlobalRdrElt`s to consider relevant
-> NameSpace | the `NameSpace` of the thing we are looking up
-> GlobalRdrElt | the `GlobalRdrElt` we have looked up, in a potentially different `NameSpace` than we wanted
-> Bool |

After looking up something with the given `NameSpace`, is the resulting `GlobalRdrElt` we have obtained relevant, according to the `RelevantGREs` specification of which `NameSpace`s are relevant?

data LookupChild #

Constructors

LookupChild |
Fields wantedParent :: Name the parent we are looking up children of lookupDataConFirst :: Bool for type constructors, should we look in the data constructor namespace first? prioritiseParent :: Bool should we prioritise getting the right `Parent`? `True`: prioritise getting the right `Parent` `False`: prioritise getting the right `NameSpace` See Note [childGREPriority].

#### Instances

Instances details

Outputable LookupChild # |
Instance details Defined in GHC.Types.Name.Reader Methods ppr :: LookupChild -> SDoc #

lookupGRE_Name :: Outputable info => GlobalRdrEnvX info -> Name -> Maybe (GlobalRdrEltX info) #

Look for precisely this `Name` in the environment, in the same `NameSpace` as the `Name`.

This tests whether it is in scope, ignoring anything else that might be in scope which doesn't have the same `Unique`.

lookupGRE_FieldLabel :: GlobalRdrEnv -> FieldLabel -> Maybe FieldGlobalRdrElt #

Look for a particular record field selector in the environment.

getGRE_NameQualifier_maybes :: GlobalRdrEnv -> Name -> [Maybe [ModuleName]] #

transformGREs :: (GlobalRdrElt -> GlobalRdrElt) -> [OccName] -> GlobalRdrEnv -> GlobalRdrEnv #

Apply a transformation function to the GREs for these OccNames

pickGREs :: RdrName -> [GlobalRdrEltX info] -> [GlobalRdrEltX info] #

Takes a list of GREs which have the right OccName `x` Pick those GREs that 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 -> [GlobalRdrEltX info] -> [(GlobalRdrEltX info, GlobalRdrEltX info)] #

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 `exports_from_avail`

# GlobalRdrElts

availFromGRE :: GlobalRdrEltX info -> AvailInfo #

greRdrNames :: GlobalRdrEltX info -> [RdrName] #

greSrcSpan :: Outputable info => GlobalRdrEltX info -> SrcSpan #

greQualModName :: Outputable info => GlobalRdrEltX info -> ModuleName #

gresToAvailInfo :: [GlobalRdrEltX info] -> [AvailInfo] #

Takes a list of distinct GREs and folds them into AvailInfos. This is more efficient than mapping each individual GRE to an AvailInfo and then folding using `plusAvail`, but needs the uniqueness assumption.

greDefinitionModule :: GlobalRdrEltX info -> Maybe Module #

The module in which the name pointed to by the GRE is defined.

greDefinitionSrcSpan :: GlobalRdrEltX info -> SrcSpan #

The SrcSpan of the name pointed to by the GRE.

greFieldLabel_maybe :: GlobalRdrElt -> Maybe FieldLabel #

Returns the field label of this GRE, if it has one

## Global `RdrName` mapping elements: `GlobalRdrElt`, `Provenance`, `ImportSpec`

data GlobalRdrEltX info #

Global Reader Element

Something in scope in the renamer; usually a member of the `GlobalRdrEnv`. See Note [GlobalRdrElt provenance].

Why do we parametrise over the `gre_info` field? See Note [IfGlobalRdrEnv].

Constructors

GRE |
Fields gre_name :: !Name gre_par :: !Parent See Note [Parents] gre_lcl :: !Bool True = the thing was defined locally gre_imp :: !(Bag ImportSpec) In scope through these imports See Note [GlobalRdrElt provenance] for the relation between gre_lcl and gre_imp. gre_info :: info Information the renamer knows about this particular `Name`. Careful about forcing this field! Forcing it can trigger the loading of interface files. Note [Retrieving the GREInfo from interfaces] in GHC.Types.GREInfo.

#### Instances

Instances details

NFData a => NFData (GlobalRdrEltX a) # |
Instance details Defined in GHC.Types.Name.Reader Methods rnf :: GlobalRdrEltX a -> () #
Data info => Data (GlobalRdrEltX info) # |
Instance details Defined in GHC.Types.Name.Reader Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> GlobalRdrEltX info -> c (GlobalRdrEltX info) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (GlobalRdrEltX info) # toConstr :: GlobalRdrEltX info -> Constr # dataTypeOf :: GlobalRdrEltX info -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (GlobalRdrEltX info)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (GlobalRdrEltX info)) # gmapT :: (forall b. Data b => b -> b) -> GlobalRdrEltX info -> GlobalRdrEltX info # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> GlobalRdrEltX info -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> GlobalRdrEltX info -> r # gmapQ :: (forall d. Data d => d -> u) -> GlobalRdrEltX info -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> GlobalRdrEltX info -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> GlobalRdrEltX info -> m (GlobalRdrEltX info) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> GlobalRdrEltX info -> m (GlobalRdrEltX info) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> GlobalRdrEltX info -> m (GlobalRdrEltX info) #
HasOccName (GlobalRdrEltX info) # |
Instance details Defined in GHC.Types.Name.Reader Methods occName :: GlobalRdrEltX info -> OccName #
Outputable info => Outputable (GlobalRdrEltX info) # |
Instance details Defined in GHC.Types.Name.Reader Methods ppr :: GlobalRdrEltX info -> SDoc #

type GlobalRdrElt = GlobalRdrEltX GREInfo #

Global Reader Element

Something in scope in the renamer; usually a member of the `GlobalRdrEnv`. See Note [GlobalRdrElt provenance].

type IfGlobalRdrElt = GlobalRdrEltX () #

A `GlobalRdrElt` in which we stripped out the `GREInfo` field, in order to avoid space leaks.

See Note [IfGlobalRdrEnv].

type FieldGlobalRdrElt = GlobalRdrElt #

A `FieldGlobalRdrElt` is a `GlobalRdrElt` in which the `gre_info` field is `IAmRecField`.

greName :: GlobalRdrEltX info -> Name #

greNameSpace :: GlobalRdrEltX info -> NameSpace #

greParent :: GlobalRdrEltX info -> Parent #

greInfo :: GlobalRdrElt -> GREInfo #

plusGRE :: GlobalRdrElt -> GlobalRdrElt -> GlobalRdrElt #

insertGRE :: GlobalRdrElt -> [GlobalRdrElt] -> [GlobalRdrElt] #

forceGlobalRdrEnv :: GlobalRdrEnvX info -> IfGlobalRdrEnv #

Drop all `GREInfo` fields in a `GlobalRdrEnv` in order to avoid space leaks. See Note [Forcing GREInfo] in GHC.Types.GREInfo.

hydrateGlobalRdrEnv :: (Name -> IO info) -> GlobalRdrEnvX noInfo -> GlobalRdrEnvX info #

Hydrate a previously dehydrated `GlobalRdrEnv`, by (lazily!) looking up the `GREInfo` using the provided function.

See Note [Forcing GREInfo] in GHC.Types.GREInfo.

isLocalGRE :: GlobalRdrEltX info -> Bool #

Is this `GlobalRdrElt` defined locally?

isImportedGRE :: GlobalRdrEltX info -> Bool #

Is this `GlobalRdrElt` imported?

Not just the negation of `isLocalGRE`, because it might be an Exact or Orig name reference. See Note [GlobalRdrElt provenance].

isRecFldGRE :: GlobalRdrEltX info -> Bool #

Is this a record field GRE?

Important: does not consult the `GreInfo` field.

fieldGREInfo :: HasDebugCallStack => FieldGlobalRdrElt -> RecFieldInfo #

isDuplicateRecFldGRE :: GlobalRdrElt -> Bool #

Is this a record field defined with DuplicateRecordFields?

isNoFieldSelectorGRE :: GlobalRdrElt -> Bool #

Is this a record field defined with NoFieldSelectors? (See Note [NoFieldSelectors] in GHC.Rename.Env)

isFieldSelectorGRE :: GlobalRdrElt -> Bool #

Is this a record field defined with FieldSelectors? (See Note [NoFieldSelectors] in GHC.Rename.Env)

unQualOK :: GlobalRdrEltX info -> Bool #

Test if an unqualified version of this thing would be in scope

qualSpecOK :: ModuleName -> ImportSpec -> Bool #

Is in scope qualified with the given module?

unQualSpecOK :: ImportSpec -> Bool #

Is in scope unqualified?

pprNameProvenance :: GlobalRdrEltX info -> SDoc #

Print out one place where the name was define/imported (With -dppr-debug, print them all)

mkGRE :: (Name -> Maybe ImportSpec) -> GREInfo -> Parent -> Name -> GlobalRdrElt #

mkExactGRE :: Name -> GREInfo -> GlobalRdrElt #

mkLocalGRE :: GREInfo -> Parent -> Name -> GlobalRdrElt #

mkLocalVanillaGRE :: Parent -> Name -> GlobalRdrElt #

mkLocalTyConGRE :: TyConFlavour Name -> Name -> GlobalRdrElt #

Create a local `GlobalRdrElt` for a `TyCon`.

mkLocalConLikeGRE :: Parent -> (ConLikeName, ConInfo) -> GlobalRdrElt #

mkLocalFieldGREs :: Parent -> [(ConLikeName, ConInfo)] -> [GlobalRdrElt] #

gresToNameSet :: [GlobalRdrEltX info] -> NameSet #

## Shadowing

greClashesWith :: GlobalRdrElt -> GlobalRdrElt -> Bool #

`greClashesWith new_gre old_gre` computes whether `new_gre` clashes with `old_gre` (assuming they both have the same underlying `occNameFS`).

shadowNames #

Arguments

:: Bool | discard names that are only available qualified?
-> GlobalRdrEnv |
-> GlobalRdrEnv |
-> GlobalRdrEnv |

## Information attached to a `GlobalRdrElt`

data ConLikeName #

The `Name` of a `ConLike`.

Useful when we are in the renamer and don't yet have a full `DataCon` or `PatSyn` to hand.

Constructors

DataConName |
Fields conLikeName_Name :: !Name
PatSynName |
Fields conLikeName_Name :: !Name

#### Instances

Instances details

NFData ConLikeName # |
Instance details Defined in GHC.Types.GREInfo Methods rnf :: ConLikeName -> () #
Data ConLikeName # |
Instance details Defined in GHC.Types.GREInfo Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ConLikeName -> c ConLikeName # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ConLikeName # toConstr :: ConLikeName -> Constr # dataTypeOf :: ConLikeName -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c ConLikeName) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ConLikeName) # gmapT :: (forall b. Data b => b -> b) -> ConLikeName -> ConLikeName # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ConLikeName -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ConLikeName -> r # gmapQ :: (forall d. Data d => d -> u) -> ConLikeName -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> ConLikeName -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> ConLikeName -> m ConLikeName # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ConLikeName -> m ConLikeName # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ConLikeName -> m ConLikeName #
Uniquable ConLikeName # |
Instance details Defined in GHC.Types.GREInfo Methods getUnique :: ConLikeName -> Unique #
Outputable ConLikeName # |
Instance details Defined in GHC.Types.GREInfo Methods ppr :: ConLikeName -> SDoc #
Eq ConLikeName # |
Instance details Defined in GHC.Types.GREInfo Methods (==) :: ConLikeName -> ConLikeName -> Bool # (/=) :: ConLikeName -> ConLikeName -> Bool #

data GREInfo #

Information about a `Name` that is pertinent to the renamer.

See Note [GREInfo]

Constructors

Vanilla | No particular information... e.g. a function
UnboundGRE | An unbound GRE... could be anything
IAmTyCon !(TyConFlavour Name) | `TyCon`
IAmConLike | `ConLike`
Fields !ConInfo The constructor fields. See Note [Local constructor info in the renamer]. | Record field
IAmRecField !RecFieldInfo |

#### Instances

Instances details

NFData GREInfo # |
Instance details Defined in GHC.Types.GREInfo Methods rnf :: GREInfo -> () #
Data GREInfo # |
Instance details Defined in GHC.Types.GREInfo Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> GREInfo -> c GREInfo # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c GREInfo # toConstr :: GREInfo -> Constr # dataTypeOf :: GREInfo -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c GREInfo) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c GREInfo) # gmapT :: (forall b. Data b => b -> b) -> GREInfo -> GREInfo # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> GREInfo -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> GREInfo -> r # gmapQ :: (forall d. Data d => d -> u) -> GREInfo -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> GREInfo -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> GREInfo -> m GREInfo # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> GREInfo -> m GREInfo # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> GREInfo -> m GREInfo #
Outputable GREInfo # |
Instance details Defined in GHC.Types.GREInfo Methods ppr :: GREInfo -> SDoc #

data RecFieldInfo #

Constructors

RecFieldInfo |
Fields recFieldLabel :: !FieldLabel recFieldCons :: !(UniqSet ConLikeName) The constructors which have this field label. Always non-empty. NB: these constructors will always share a single parent, as the field label disambiguates between parents in the presence of duplicate record fields.

#### Instances

Instances details

NFData RecFieldInfo # |
Instance details Defined in GHC.Types.GREInfo Methods rnf :: RecFieldInfo -> () #
Data RecFieldInfo # |
Instance details Defined in GHC.Types.GREInfo Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> RecFieldInfo -> c RecFieldInfo # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c RecFieldInfo # toConstr :: RecFieldInfo -> Constr # dataTypeOf :: RecFieldInfo -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c RecFieldInfo) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c RecFieldInfo) # gmapT :: (forall b. Data b => b -> b) -> RecFieldInfo -> RecFieldInfo # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> RecFieldInfo -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> RecFieldInfo -> r # gmapQ :: (forall d. Data d => d -> u) -> RecFieldInfo -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> RecFieldInfo -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> RecFieldInfo -> m RecFieldInfo # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> RecFieldInfo -> m RecFieldInfo # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> RecFieldInfo -> m RecFieldInfo #
Outputable RecFieldInfo # |
Instance details Defined in GHC.Types.GREInfo Methods ppr :: RecFieldInfo -> SDoc #
Eq RecFieldInfo # |
Instance details Defined in GHC.Types.GREInfo Methods (==) :: RecFieldInfo -> RecFieldInfo -> Bool # (/=) :: RecFieldInfo -> RecFieldInfo -> Bool #

plusGREInfo :: GREInfo -> GREInfo -> GREInfo #

recFieldConLike_maybe :: HasDebugCallStack => GlobalRdrElt -> Maybe ConInfo #

recFieldInfo_maybe :: HasDebugCallStack => GlobalRdrElt -> Maybe RecFieldInfo #

fieldGRE_maybe :: GlobalRdrElt -> Maybe FieldGlobalRdrElt #

fieldGRELabel :: HasDebugCallStack => FieldGlobalRdrElt -> FieldLabel #

## Parent information

data Parent #

See Note [Parents]

Constructors

NoParent |
ParentIs |
Fields par_is :: !Name

#### Instances

Instances details

NFData Parent # |
Instance details Defined in GHC.Types.Name.Reader Methods rnf :: Parent -> () #
Data Parent # |
Instance details Defined in GHC.Types.Name.Reader Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Parent -> c Parent # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Parent # toConstr :: Parent -> Constr # dataTypeOf :: Parent -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Parent) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Parent) # gmapT :: (forall b. Data b => b -> b) -> Parent -> Parent # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Parent -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Parent -> r # gmapQ :: (forall d. Data d => d -> u) -> Parent -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Parent -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Parent -> m Parent # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Parent -> m Parent # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Parent -> m Parent #
Outputable Parent # |
Instance details Defined in GHC.Types.Name.Reader Methods ppr :: Parent -> SDoc #
Eq Parent # |
Instance details Defined in GHC.Types.Name.Reader Methods (==) :: Parent -> Parent -> Bool # (/=) :: Parent -> Parent -> Bool #

greParent_maybe :: GlobalRdrEltX info -> Maybe Name #

mkParent :: Name -> AvailInfo -> Parent #

availParent :: AvailInfo -> Parent #

data ImportSpec #

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.

Constructors

ImpSpec |
Fields is_decl :: !ImpDeclSpec is_item :: !ImpItemSpec

#### Instances

Instances details

NFData ImportSpec # |
Instance details Defined in GHC.Types.Name.Reader Methods rnf :: ImportSpec -> () #
Data ImportSpec # |
Instance details Defined in GHC.Types.Name.Reader Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ImportSpec -> c ImportSpec # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ImportSpec # toConstr :: ImportSpec -> Constr # dataTypeOf :: ImportSpec -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c ImportSpec) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ImportSpec) # gmapT :: (forall b. Data b => b -> b) -> ImportSpec -> ImportSpec # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ImportSpec -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ImportSpec -> r # gmapQ :: (forall d. Data d => d -> u) -> ImportSpec -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> ImportSpec -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> ImportSpec -> m ImportSpec # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ImportSpec -> m ImportSpec # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ImportSpec -> m ImportSpec #
Outputable ImportSpec # |
Instance details Defined in GHC.Types.Name.Reader Methods ppr :: ImportSpec -> SDoc #
Eq ImportSpec # |
Instance details Defined in GHC.Types.Name.Reader Methods (==) :: ImportSpec -> ImportSpec -> Bool # (/=) :: ImportSpec -> ImportSpec -> Bool #

data ImpDeclSpec #

Import Declaration Specification

Describes a particular import declaration and is shared among all the `Provenance`s for that decl

Constructors

ImpDeclSpec |
Fields is_mod :: !Module Module imported, e.g. `import Muggle` Note the `Muggle` may well not be the defining module for this thing! is_as :: !ModuleName Import alias, e.g. from `as M` (or `Muggle` if there is no `as` clause) is_qual :: !Bool Was this import qualified? is_dloc :: !SrcSpan The location of the entire import declaration

#### Instances

Instances details

Data ImpDeclSpec # |
Instance details Defined in GHC.Types.Name.Reader Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ImpDeclSpec -> c ImpDeclSpec # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ImpDeclSpec # toConstr :: ImpDeclSpec -> Constr # dataTypeOf :: ImpDeclSpec -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c ImpDeclSpec) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ImpDeclSpec) # gmapT :: (forall b. Data b => b -> b) -> ImpDeclSpec -> ImpDeclSpec # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ImpDeclSpec -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ImpDeclSpec -> r # gmapQ :: (forall d. Data d => d -> u) -> ImpDeclSpec -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> ImpDeclSpec -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> ImpDeclSpec -> m ImpDeclSpec # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ImpDeclSpec -> m ImpDeclSpec # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ImpDeclSpec -> m ImpDeclSpec #
Eq ImpDeclSpec # |
Instance details Defined in GHC.Types.Name.Reader Methods (==) :: ImpDeclSpec -> ImpDeclSpec -> Bool # (/=) :: ImpDeclSpec -> ImpDeclSpec -> Bool #

data ImpItemSpec #

Import Item Specification

Describes import info a particular Name

Constructors

ImpAll | The import had no import list, or had a hiding list
ImpSome | The import had an import list. The `is_explicit` field is `True` iff the thing was named explicitly in the import specs rather than being imported as part of a "..." group. Consider:
    import C( T(..) )
Here the constructors of `T` are not named explicitly; only `T` is named explicitly.
Fields is_explicit :: !Bool is_iloc :: !SrcSpan

#### Instances

Instances details

Data ImpItemSpec # |
Instance details Defined in GHC.Types.Name.Reader Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ImpItemSpec -> c ImpItemSpec # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ImpItemSpec # toConstr :: ImpItemSpec -> Constr # dataTypeOf :: ImpItemSpec -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c ImpItemSpec) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ImpItemSpec) # gmapT :: (forall b. Data b => b -> b) -> ImpItemSpec -> ImpItemSpec # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ImpItemSpec -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ImpItemSpec -> r # gmapQ :: (forall d. Data d => d -> u) -> ImpItemSpec -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> ImpItemSpec -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> ImpItemSpec -> m ImpItemSpec # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ImpItemSpec -> m ImpItemSpec # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ImpItemSpec -> m ImpItemSpec #
Eq ImpItemSpec # |
Instance details Defined in GHC.Types.Name.Reader Methods (==) :: ImpItemSpec -> ImpItemSpec -> Bool # (/=) :: ImpItemSpec -> ImpItemSpec -> Bool #

importSpecLoc :: ImportSpec -> SrcSpan #

importSpecModule :: ImportSpec -> ModuleName #

isExplicitItem :: ImpItemSpec -> Bool #

bestImport :: NonEmpty ImportSpec -> ImportSpec #

# Utils

opIsAt :: RdrName -> Bool #

Indicate if the given name is the "@" operator