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

Safe HaskellNone
LanguageHaskell2010

Name

Description

GHC uses several kinds of name internally:

  • OccName : see OccName
  • RdrName : see RdrName
  • Name is the type of names that have had their scoping and binding resolved. They have an OccName but also a Unique that disambiguates Names that have the same OccName and indeed is used for all Name comparison. Names also contain information about where they originated from, see Name
  • Id : see Id
  • Var : see Var

Names are one of:

  • External, if they name things declared in other modules. Some external Names are wired in, i.e. they name primitives defined in the compiler itself
  • Internal, if they name things in the module being compiled. Some internal Names are system names, if they are names manufactured by the compiler
Synopsis

The main types

data Name Source #

A unique, unambiguous name for something, containing information about where that thing originated.

Instances
Eq Name Source #

The same comments as for Name 's Ord instance apply.

Instance details

Defined in Name

Methods

(==) :: Name -> Name -> Bool #

(/=) :: Name -> Name -> Bool #

Instance details

Defined in Name

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Name -> c Name #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Name #

toConstr :: Name -> Constr #

dataTypeOf :: Name -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Name) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Name) #

gmapT :: (forall b. Data b => b -> b) -> Name -> Name #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Name -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Name -> r #

gmapQ :: (forall d. Data d => d -> u) -> Name -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Name -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Name -> m Name #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Name -> m Name #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Name -> m Name #

Ord Name Source #

Caution: This instance is implemented via nonDetCmpUnique , which means that the ordering is not stable across deserialization or rebuilds.

See nonDetCmpUnique for further information, and trac #15240 for a bug caused by improper use of this instance.

Instance details

Defined in Name

Methods

compare :: Name -> Name -> Ordering #

(<) :: Name -> Name -> Bool #

(<=) :: Name -> Name -> Bool #

(>) :: Name -> Name -> Bool #

(>=) :: Name -> Name -> Bool #

max :: Name -> Name -> Name #

min :: Name -> Name -> Name #

Instance details

Defined in Name

Methods

rnf :: Name -> () #

Instance details

Defined in Name

Instance details

Defined in Name

Methods

ppr :: Name -> SDoc Source #

pprPrec :: Rational -> Name -> SDoc Source #

Instance details

Defined in Name

Methods

getUnique :: Name -> Unique Source #

Binary Name Source #

Assumes that the Name is a non-binding one. See putIfaceTopBndr and getIfaceTopBndr for serializing binding Name s. See UserData for the rationale for this distinction.

Instance details

Defined in Name

Methods

put_ :: BinHandle -> Name -> IO () Source #

put :: BinHandle -> Name -> IO (Bin Name) Source #

get :: BinHandle -> IO Name Source #

Instance details

Defined in Name

Methods

occName :: Name -> OccName Source #

Instance details

Defined in Name

Instance details

Defined in Name

data BuiltInSyntax Source #

BuiltInSyntax is for things like (:), [] and tuples, which have special syntactic forms. They aren't in scope as such.

Constructors

Creating Name s

mkSystemName :: Unique -> OccName -> Name Source #

Create a name brought into being by the compiler

mkSystemNameAt :: Unique -> OccName -> SrcSpan -> Name Source #

mkInternalName :: Unique -> OccName -> SrcSpan -> Name Source #

Create a name which is (for now at least) local to the current module and hence does not need a Module to disambiguate it from other Name s

mkClonedInternalName :: Unique -> Name -> Name Source #

mkDerivedInternalName :: (OccName -> OccName) -> Unique -> Name -> Name Source #

mkSystemVarName :: Unique -> FastString -> Name Source #

mkSysTvName :: Unique -> FastString -> Name Source #

mkFCallName :: Unique -> String -> Name Source #

Make a name for a foreign call

mkExternalName :: Unique -> Module -> OccName -> SrcSpan -> Name Source #

Create a name which definitely originates in the given module

mkWiredInName :: Module -> OccName -> Unique -> TyThing -> BuiltInSyntax -> Name Source #

Create a name which is actually defined by the compiler itself

Manipulating and deconstructing Name s

nameUnique :: Name -> Unique Source #

setNameUnique :: Name -> Unique -> Name Source #

nameOccName :: Name -> OccName Source #

nameModule :: HasDebugCallStack => Name -> Module Source #

nameModule_maybe :: Name -> Maybe Module Source #

setNameLoc :: Name -> SrcSpan -> Name Source #

tidyNameOcc :: Name -> OccName -> Name Source #

localiseName :: Name -> Name Source #

Make the Name into an internal name, regardless of what it was to begin with

nameSrcLoc :: Name -> SrcLoc Source #

nameSrcSpan :: Name -> SrcSpan Source #

pprNameDefnLoc :: Name -> SDoc Source #

pprDefinedAt :: Name -> SDoc Source #

Predicates on Name s

isSystemName :: Name -> Bool Source #

isInternalName :: Name -> Bool Source #

isExternalName :: Name -> Bool Source #

isTyVarName :: Name -> Bool Source #

isTyConName :: Name -> Bool Source #

isDataConName :: Name -> Bool Source #

isValName :: Name -> Bool Source #

isVarName :: Name -> Bool Source #

isWiredInName :: Name -> Bool Source #

isBuiltInSyntax :: Name -> Bool Source #

isHoleName :: Name -> Bool Source #

wiredInNameTyThing_maybe :: Name -> Maybe TyThing Source #

nameIsLocalOrFrom :: Module -> Name -> Bool Source #

Returns True if the name is (a) Internal (b) External but from the specified module (c) External but from the interactive package

The key idea is that False means: the entity is defined in some other module you can find the details (type, fixity, instances) in some interface file those details will be stored in the EPT or HPT

True means: the entity is defined in this module or earlier in the GHCi session you can find details (type, fixity, instances) in the TcGblEnv or TcLclEnv

The isInteractiveModule part is because successive interactions of a GHCi session each give rise to a fresh module (Ghci1, Ghci2, etc), but they all come from the magic interactive package; and all the details are kept in the TcLclEnv, TcGblEnv, NOT in the HPT or EPT. See Note [The interactive package] in HscTypes

nameIsHomePackage :: Module -> Name -> Bool Source #

nameIsHomePackageImport :: Module -> Name -> Bool Source #

nameIsFromExternalPackage :: UnitId -> Name -> Bool Source #

Returns True if the Name comes from some other package: neither this package nor the interactive package.

stableNameCmp :: Name -> Name -> Ordering Source #

Compare Names lexicographically This only works for Names that originate in the source code or have been tidied.

Class NamedThing and overloaded friends

class NamedThing a where Source #

A class allowing convenient access to the Name of various datatypes

Minimal complete definition

getName

Methods

getOccName :: a -> OccName Source #

getName :: a -> Name Source #

Instances
Instance details

Defined in Name

Instance details

Defined in TyCon

Instance details

Defined in Var

Instance details

Defined in TyCoRep

Instance details

Defined in PatSyn

Instance details

Defined in DataCon

Instance details

Defined in ConLike

Instance details

Defined in Class

Instance details

Defined in IfaceSyn

Instance details

Defined in IfaceSyn

Instance details

Defined in IfaceSyn

Instance details

Defined in FamInstEnv

Instance details

Defined in InstEnv

Instance details

Defined in Name

Instance details

Defined in CoAxiom

Instance details

Defined in Var

Methods

getOccName :: VarBndr tv flag -> OccName Source #

getName :: VarBndr tv flag -> Name Source #

getSrcLoc :: NamedThing a => a -> SrcLoc Source #

getSrcSpan :: NamedThing a => a -> SrcSpan Source #

getOccString :: NamedThing a => a -> String Source #

getOccFS :: NamedThing a => a -> FastString Source #

pprInfixName :: (Outputable a, NamedThing a) => a -> SDoc Source #

pprPrefixName :: NamedThing a => a -> SDoc Source #

pprModulePrefix :: PprStyle -> Module -> OccName -> SDoc Source #

pprNameUnqualified :: Name -> SDoc Source #

Print the string of Name unqualifiedly directly.

nameStableString :: Name -> String Source #

Get a string representation of a Name that's unique and stable across recompilations. Used for deterministic generation of binds for derived instances. eg. "$aeson_70dylHtv1FFGeai1IoxcQr$Data.Aeson.Types.Internal$String"

module OccName

AltStyle によって変換されたページ (->オリジナル) /