GHC.Rename.Env

ghc-9.10.0.20240426: The GHC API

Safe Haskell | None
Language | GHC2021

GHC.Rename.Env

Synopsis

- newTopSrcBinder :: LocatedN RdrName -> RnM Name
- lookupLocatedTopBndrRn :: Located RdrName -> RnM (Located Name)
- lookupLocatedTopBndrRnN :: LocatedN RdrName -> RnM (LocatedN Name)
- lookupTopBndrRn :: WhatLooking -> RdrName -> RnM Name
- lookupLocatedTopConstructorRn :: Located RdrName -> RnM (Located Name)
- lookupLocatedTopConstructorRnN :: LocatedN RdrName -> RnM (LocatedN Name)
- lookupLocatedOccRn :: GenLocated (EpAnn ann) RdrName -> TcRn (GenLocated (EpAnn ann) Name)
- lookupLocatedOccRnConstr :: GenLocated (EpAnn ann) RdrName -> TcRn (GenLocated (EpAnn ann) Name)
- lookupLocatedOccRnRecField :: GenLocated (EpAnn ann) RdrName -> TcRn (GenLocated (EpAnn ann) Name)
- lookupLocatedOccRnNone :: GenLocated (EpAnn ann) RdrName -> TcRn (GenLocated (EpAnn ann) Name)
- lookupOccRn :: RdrName -> RnM Name
- lookupOccRn_maybe :: RdrName -> RnM (Maybe GlobalRdrElt)
- lookupSameOccRn_maybe :: RdrName -> RnM (Maybe Name)
- lookupLocalOccRn_maybe :: RdrName -> RnM (Maybe Name)
- lookupInfoOccRn :: RdrName -> RnM [Name]
- lookupLocalOccThLvl_maybe :: Name -> RnM (Maybe (TopLevelFlag, ThLevel))
- lookupLocalOccRn :: RdrName -> RnM Name
- lookupTypeOccRn :: RdrName -> RnM Name
- lookupGlobalOccRn :: RdrName -> RnM Name
- lookupGlobalOccRn_maybe :: WhichGREs GREInfo -> RdrName -> RnM (Maybe GlobalRdrElt)
- lookupExprOccRn :: RdrName -> RnM (Maybe GlobalRdrElt)
- lookupRecFieldOcc :: Maybe Name -> RdrName -> RnM Name
- lookupRecUpdFields :: NonEmpty (LHsRecUpdField GhcPs GhcPs) -> RnM (NonEmpty (HsRecUpdParent GhcRn))
- getFieldUpdLbl :: forall (p :: Pass) q. LHsRecUpdField (GhcPass p) q -> LocatedN RdrName
- getUpdFieldLbls :: forall (p :: Pass) q. UnXRec (GhcPass p) => [LHsRecUpdField (GhcPass p) q] -> [RdrName]
- data ChildLookupResult
  - = NameNotFound
  - | IncorrectParent Name GlobalRdrElt [Name]
  - | FoundChild GlobalRdrElt
- lookupSubBndrOcc_helper :: Bool -> DeprecationWarnings -> Name -> RdrName -> LookupChild -> RnM ChildLookupResult
- data HsSigCtxt
  - = TopSigCtxt NameSet
  - | LocalBindCtxt NameSet
  - | ClsDeclCtxt Name
  - | InstDeclCtxt NameSet
  - | HsBootCtxt NameSet
  - | RoleAnnotCtxt NameSet
- lookupLocalTcNames :: HsSigCtxt -> SDoc -> NamespaceSpecifier -> RdrName -> RnM [(RdrName, Name)]
- lookupSigOccRn :: HsSigCtxt -> Sig GhcPs -> LocatedA RdrName -> RnM (LocatedA Name)
- lookupSigOccRnN :: HsSigCtxt -> Sig GhcPs -> LocatedN RdrName -> RnM (LocatedN Name)
- lookupSigCtxtOccRn :: HsSigCtxt -> SDoc -> GenLocated (EpAnn ann) RdrName -> RnM (GenLocated (EpAnn ann) Name)
- lookupInstDeclBndr :: Name -> SDoc -> RdrName -> RnM Name
- lookupFamInstName :: Maybe Name -> LocatedN RdrName -> RnM (LocatedN Name)
- lookupConstructorInfo :: HasDebugCallStack => Name -> RnM ConInfo
- lookupConstructorFields :: HasDebugCallStack => Name -> RnM [FieldLabel]
- lookupGREInfo :: HasDebugCallStack => HscEnv -> Name -> GREInfo
- lookupGreAvailRn :: RdrName -> RnM (Maybe GlobalRdrElt)
- lookupSyntax :: Name -> RnM (SyntaxExpr GhcRn, FreeVars)
- lookupSyntaxExpr :: Name -> RnM (HsExpr GhcRn, FreeVars)
- lookupSyntaxNames :: [Name] -> RnM ([HsExpr GhcRn], FreeVars)
- lookupSyntaxName :: Name -> RnM (Name, FreeVars)
- lookupIfThenElse :: RnM (Maybe Name)
- lookupQualifiedDoExpr :: HsStmtContext fn -> Name -> RnM (HsExpr GhcRn, FreeVars)
- lookupQualifiedDo :: HsStmtContext fn -> Name -> RnM (SyntaxExpr GhcRn, FreeVars)
- lookupQualifiedDoName :: HsStmtContext fn -> Name -> RnM (Name, FreeVars)
- lookupNameWithQualifier :: Name -> ModuleName -> RnM (Name, FreeVars)
- data DeprecationWarnings
  - = NoDeprecationWarnings
  - | ExportDeprecationWarnings
  - | AllDeprecationWarnings
- addUsedGRE :: DeprecationWarnings -> GlobalRdrElt -> RnM ()
- addUsedGREs :: DeprecationWarnings -> [GlobalRdrElt] -> RnM ()
- addUsedDataCons :: GlobalRdrEnv -> TyCon -> RnM ()
- dataTcOccs :: RdrName -> [RdrName]

# Documentation

newTopSrcBinder :: LocatedN RdrName -> RnM Name Source #

lookupLocatedTopBndrRn :: Located RdrName -> RnM (Located Name) Source #

lookupLocatedTopBndrRnN :: LocatedN RdrName -> RnM (LocatedN Name) Source #

lookupTopBndrRn :: WhatLooking -> RdrName -> RnM Name Source #

lookupLocatedTopConstructorRn :: Located RdrName -> RnM (Located Name) Source #

lookupLocatedTopConstructorRnN :: LocatedN RdrName -> RnM (LocatedN Name) Source #

lookupLocatedOccRn :: GenLocated (EpAnn ann) RdrName -> TcRn (GenLocated (EpAnn ann) Name) Source #

lookupLocatedOccRnConstr :: GenLocated (EpAnn ann) RdrName -> TcRn (GenLocated (EpAnn ann) Name) Source #

lookupLocatedOccRnRecField :: GenLocated (EpAnn ann) RdrName -> TcRn (GenLocated (EpAnn ann) Name) Source #

lookupLocatedOccRnNone :: GenLocated (EpAnn ann) RdrName -> TcRn (GenLocated (EpAnn ann) Name) Source #

lookupOccRn :: RdrName -> RnM Name Source #

lookupOccRn_maybe :: RdrName -> RnM (Maybe GlobalRdrElt) Source #

lookupSameOccRn_maybe :: RdrName -> RnM (Maybe Name) Source #

lookupLocalOccRn_maybe :: RdrName -> RnM (Maybe Name) Source #

lookupInfoOccRn :: RdrName -> RnM [Name] Source #

lookupInfoOccRn is intended for use in GHCi's ":info" command It finds all the GREs that RdrName could mean, not complaining about ambiguity, but rather returning them all (c.f. #9881).

lookupInfoOccRn is also used in situations where we check for at least one definition of the RdrName, not complaining about multiple definitions (see #17832).

lookupLocalOccThLvl_maybe :: Name -> RnM (Maybe (TopLevelFlag, ThLevel)) Source #

lookupLocalOccRn :: RdrName -> RnM Name Source #

lookupTypeOccRn :: RdrName -> RnM Name Source #

lookupGlobalOccRn :: RdrName -> RnM Name Source #

lookupGlobalOccRn_maybe :: WhichGREs GREInfo -> RdrName -> RnM (Maybe GlobalRdrElt) Source #

lookupExprOccRn :: RdrName -> RnM (Maybe GlobalRdrElt) Source #

Look up a `RdrName` used as a variable in an expression.

This may be a local variable, global variable, or one or more record selector functions. It will not return record fields created with the `NoFieldSelectors` extension (see Note [NoFieldSelectors]).

If the name is not in scope at the term level, but its promoted equivalent is in scope at the type level, the lookup will succeed (so that the type-checker can report a more informative error later). See Note [Promotion].

lookupRecFieldOcc :: Maybe Name -> RdrName -> RnM Name Source #

Look up an occurrence of a field in record construction or pattern matching (but not update).

If -XDisambiguateRecordFields is off, then we will pass `Nothing` for the `DataCon` `Name`, i.e. we don't use the data constructor for disambiguation. See Note [DisambiguateRecordFields] and Note [NoFieldSelectors].

lookupRecUpdFields :: NonEmpty (LHsRecUpdField GhcPs GhcPs) -> RnM (NonEmpty (HsRecUpdParent GhcRn)) Source #

Returns all possible collections of field labels for the given record update.

Example:

data D = MkD { fld1 :: Int, fld2 :: Bool } data E = MkE1 { fld1 :: Int, fld2 :: Bool, fld3 :: Char } | MkE2 { fld1 :: Int, fld2 :: Bool } data F = MkF1 { fld1 :: Int } | MkF2 { fld2 :: Bool }

f r = r { fld1 = a, fld2 = b }

This function will return:

[ D.fld1, D.fld2
  -- could be a record update at type D , [ E.fld1, E.fld2 ] -- could be a record update at type E ] -- cannot be a record update at type F: no constructor has both -- of the fields fld1 and fld2

If there are no valid parents for the record update, throws a `TcRnBadRecordUpdate` error.

getFieldUpdLbl :: forall (p :: Pass) q. LHsRecUpdField (GhcPass p) q -> LocatedN RdrName Source #

getUpdFieldLbls :: forall (p :: Pass) q. UnXRec (GhcPass p) => [LHsRecUpdField (GhcPass p) q] -> [RdrName] Source #

data ChildLookupResult Source #

Constructors

NameNotFound | We couldn't find a suitable name
IncorrectParent | The child has an incorrect parent
Fields Name parent GlobalRdrElt child we were looking for [Name] list of possible parents | We resolved to a child
FoundChild GlobalRdrElt |

#### Instances

Instances details

Outputable ChildLookupResult Source # |
Instance details Defined in GHC.Rename.Env Methods ppr :: ChildLookupResult -> SDoc Source #

lookupSubBndrOcc_helper Source #

Arguments

:: Bool |
-> DeprecationWarnings |
-> Name |
-> RdrName | thing we are looking up
-> LookupChild | how to look it up (e.g. which `NameSpace`s to look in)
-> RnM ChildLookupResult |

Used in export lists to lookup the children.

data HsSigCtxt Source #

Constructors

TopSigCtxt NameSet |
LocalBindCtxt NameSet |
ClsDeclCtxt Name |
InstDeclCtxt NameSet |
HsBootCtxt NameSet |
RoleAnnotCtxt NameSet |

#### Instances

Instances details

Outputable HsSigCtxt Source # |
Instance details Defined in GHC.Rename.Env Methods ppr :: HsSigCtxt -> SDoc Source #

lookupLocalTcNames :: HsSigCtxt -> SDoc -> NamespaceSpecifier -> RdrName -> RnM [(RdrName, Name)] Source #

lookupSigOccRn :: HsSigCtxt -> Sig GhcPs -> LocatedA RdrName -> RnM (LocatedA Name) Source #

lookupSigOccRnN :: HsSigCtxt -> Sig GhcPs -> LocatedN RdrName -> RnM (LocatedN Name) Source #

lookupSigCtxtOccRn Source #

Arguments

:: HsSigCtxt |
-> SDoc | description of thing we're looking up, like "type family"
-> GenLocated (EpAnn ann) RdrName |
-> RnM (GenLocated (EpAnn ann) Name) |

Lookup a name in relation to the names in a `HsSigCtxt`

lookupInstDeclBndr :: Name -> SDoc -> RdrName -> RnM Name Source #

lookupFamInstName :: Maybe Name -> LocatedN RdrName -> RnM (LocatedN Name) Source #

lookupConstructorInfo :: HasDebugCallStack => Name -> RnM ConInfo Source #

Look up the arity and record fields of a constructor.

lookupConstructorFields :: HasDebugCallStack => Name -> RnM [FieldLabel] Source #

lookupGREInfo :: HasDebugCallStack => HscEnv -> Name -> GREInfo Source #

Look up the `GREInfo` associated with the given `Name` by looking up in the type environment.

lookupGreAvailRn :: RdrName -> RnM (Maybe GlobalRdrElt) Source #

lookupSyntax :: Name -> RnM (SyntaxExpr GhcRn, FreeVars) Source #

lookupSyntaxExpr Source #

Arguments

:: Name | The standard name
-> RnM (HsExpr GhcRn, FreeVars) | Possibly a non-standard name

lookupSyntaxNames :: [Name] -> RnM ([HsExpr GhcRn], FreeVars) Source #

lookupSyntaxName Source #

Arguments

:: Name | The standard name
-> RnM (Name, FreeVars) | Possibly a non-standard name Lookup a Name that may be subject to Rebindable Syntax (RS). When RS is off, just return the supplied (standard) Name When RS is on, look up the OccName of the supplied Name; return what we find, or the supplied Name if there is nothing in scope

lookupIfThenElse :: RnM (Maybe Name) Source #

lookupQualifiedDoExpr :: HsStmtContext fn -> Name -> RnM (HsExpr GhcRn, FreeVars) Source #

lookupQualifiedDo :: HsStmtContext fn -> Name -> RnM (SyntaxExpr GhcRn, FreeVars) Source #

lookupQualifiedDoName :: HsStmtContext fn -> Name -> RnM (Name, FreeVars) Source #

lookupNameWithQualifier :: Name -> ModuleName -> RnM (Name, FreeVars) Source #

data DeprecationWarnings Source #

Whether to report deprecation warnings when registering a used GRE

There is no option to only emit declaration warnings since everywhere we emit the declaration warnings we also emit export warnings (See Note [Handling of deprecations] for details)

Constructors

NoDeprecationWarnings |
ExportDeprecationWarnings |
AllDeprecationWarnings |

addUsedGRE :: DeprecationWarnings -> GlobalRdrElt -> RnM () Source #

addUsedGREs :: DeprecationWarnings -> [GlobalRdrElt] -> RnM () Source #

addUsedDataCons :: GlobalRdrEnv -> TyCon -> RnM () Source #

dataTcOccs :: RdrName -> [RdrName] Source #