ghc-9.2.1: The GHC API

GHC.Runtime.Context

Synopsis

Documentation

Interactive context, recording information about the state of the context in which statements are executed in a GHCi session.

Constructors

 InteractiveContext Fieldsic_dflags :: DynFlagsThe DynFlags used to evaluate interactive expressions and statements.ic_mod_index :: IntEach GHCi stmt or declaration brings some new things into scope. We give them names like interactive:Ghci9.T, where the ic_index is the '9'. The ic_mod_index is incremented whenever we add something to ic_tythings See Note [The interactive package]ic_imports :: [InteractiveImport]The GHCi top-level scope (ic_rn_gbl_env) is extended with these importsThis field is only stored here so that the client can retrieve it with GHC.getContext. GHC itself doesn't use it, but does reset it to empty sometimes (such as before a GHC.load). The context is set with GHC.setContext.ic_tythings :: [TyThing]TyThings defined by the user, in reverse order of definition (ie most recent at the front) See Note [ic_tythings]ic_rn_gbl_env :: GlobalRdrEnvThe cached GlobalRdrEnv, built by setContext and updated regularly It contains everything in scope at the command line, including everything in ic_tythingsic_instances :: ([ClsInst], [FamInst])All instances and family instances created during this session. These are grabbed en masse after each update to be sure that proper overlapping is retained. That is, rather than re-check the overlapping each time we update the context, we just take the results from the instance code that already does that.ic_fix_env :: FixityEnvFixities declared in let statementsic_default :: Maybe [Type]The current default types, set by a 'default' declarationic_resume :: [Resume]The stack of breakpoint contextsic_monad :: NameThe monad that GHCi is executing inic_int_print :: NameThe function that is used for printing results of expressions in ghci and -e mode.ic_cwd :: Maybe FilePathvirtual CWD of the programic_plugins :: ![LoadedPlugin]Cache of loaded plugins. We store them here to avoid having to load them everytime we switch to the interctive context.

Constructors

 IIDecl (ImportDecl GhcPs) Bring the exports of a particular module (filtered by an import decl) into scope IIModule ModuleName Bring into scope the entire top-level envt of of this module, including the things imported into it.

Instances

Instances details
 Source # Instance detailsDefined in GHC.Runtime.Context Methods

Constructs an empty InteractiveContext.

extendInteractiveContext :: InteractiveContext -> [TyThing] -> [ClsInst] -> [FamInst] -> Maybe [Type] -> FixityEnv -> InteractiveContext Source #

extendInteractiveContext is called with new TyThings recently defined to update the InteractiveContext to include them. Ids are easily removed when shadowed, but Classes and TyCons are not. Some work could be done to determine whether they are entirely shadowed, but as you could still have references to them (e.g. instances for classes or values of the type for TyCons), it's not clear whether removing them is even the appropriate behavior.

Add TyThings to the GlobalRdrEnv, earlier ones in the list shadowing later ones, and shadowing existing entries in the GlobalRdrEnv.

This function returns the list of visible TyThings (useful for e.g. showBindings)

Get the PrintUnqualified function based on the flags and this InteractiveContext