ghc-8.0.0.20160204: The GHC API

Safe HaskellNone
LanguageHaskell2010

InteractiveEval

Contents

Synopsis

Documentation

execStmt

Arguments

:: GhcMonad m 
=> String

a statement (bind or expression)

-> ExecOptions 
-> m ExecResult 

Run a statement in the current interactive context.

data ExecOptions

Constructors

ExecOptions 

Fields

execOptions :: ExecOptions

default ExecOptions

runDecls :: GhcMonad m => String -> m [Name]

runDeclsWithLocation :: GhcMonad m => String -> Int -> String -> m [Name]

Run some declarations and return any user-visible names that were brought into scope.

isStmt :: DynFlags -> String -> Bool

Returns True if passed string is a statement.

hasImport :: DynFlags -> String -> Bool

Returns True if passed string has an import declaration.

isImport :: DynFlags -> String -> Bool

Returns True if passed string is an import declaration.

isDecl :: DynFlags -> String -> Bool

Returns True if passed string is a declaration but not a splice.

back :: GhcMonad m => Int -> m ([Name], Int, SrcSpan, String)

forward :: GhcMonad m => Int -> m ([Name], Int, SrcSpan, String)

setContext :: GhcMonad m => [InteractiveImport] -> m ()

Set the interactive evaluation context.

(setContext imports) sets the ic_imports field (which in turn determines what is in scope at the prompt) to imports, and constructs the ic_rn_glb_env environment to reflect it.

We retain in scope all the things defined at the prompt, and kept in ic_tythings. (Indeed, they shadow stuff from ic_imports.)

getContext :: GhcMonad m => m [InteractiveImport]

Get the interactive evaluation context, consisting of a pair of the set of modules from which we take the full top-level scope, and the set of modules from which we take just the exports respectively.

getNamesInScope :: GhcMonad m => m [Name]

Returns all names in scope in the current interactive context

getRdrNamesInScope :: GhcMonad m => m [RdrName]

Returns all RdrNames in scope in the current interactive context, excluding any that are internally-generated.

moduleIsInterpreted :: GhcMonad m => Module -> m Bool

Returns True if the specified module is interpreted, and hence has its full top-level scope available.

getInfo :: GhcMonad m => Bool -> Name -> m (Maybe (TyThing, Fixity, [ClsInst], [FamInst]))

Looks up an identifier in the current interactive context (for :info) Filter the instances by the ones whose tycons (or clases resp) are in scope (qualified or otherwise). Otherwise we list a whole lot too many! The exact choice of which ones to show, and which to hide, is a judgement call. (see Trac #1581)

exprType :: GhcMonad m => String -> m Type

Get the type of an expression Returns its most general type

typeKind :: GhcMonad m => Bool -> String -> m (Type, Kind)

Get the kind of a type

parseName :: GhcMonad m => String -> m [Name]

Parses a string as an identifier, and returns the list of Names that the identifier can refer to in the current interactive context.

parseExpr :: GhcMonad m => String -> m (LHsExpr RdrName)

Parse an expression, the parsed expression can be further processed and passed to compileParsedExpr.

compileExpr :: GhcMonad m => String -> m HValue

Compile an expression, run it and deliver the resulting HValue.

dynCompileExpr :: GhcMonad m => String -> m Dynamic

Compile an expression, run it and return the result as a Dynamic.

compileExprRemote :: GhcMonad m => String -> m ForeignHValue

Compile an expression, run it and deliver the resulting HValue.

compileParsedExprRemote :: GhcMonad m => LHsExpr RdrName -> m ForeignHValue

Compile an parsed expression (before renaming), run it and deliver the resulting HValue.

data Term

Constructors

Term 

Fields

Prim 

Fields

Suspension 

Fields

NewtypeWrap 

Fields

RefWrap 

Fields

Instances

Depcreated API (remove in GHC 7.14)

data RunResult

The type returned by the deprecated runStmt and runStmtWithLocation API

Constructors

RunOk [Name]

names bound by this evaluation

RunException SomeException

statement raised an exception

RunBreak ThreadId [Name] (Maybe BreakInfo) 

runStmt :: GhcMonad m => String -> SingleStep -> m RunResult

Deprecated: use execStmt

Run a statement in the current interactive context. Statement may bind multple values.

runStmtWithLocation :: GhcMonad m => String -> Int -> String -> SingleStep -> m RunResult

Deprecated: use execStmtWithLocation