diff options
author | Simon Marlow <marlowsd@gmail.com> | 2015-06-12 13:15:18 +0100 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2015-06-12 13:15:18 +0100 |
commit | d20031d4c88b256cdae264cb05d9d850e973d956 (patch) | |
tree | 84af3e055d60d87058cfe48a7260e75859f9fefe /compiler/main/GHC.hs | |
parent | c14bd01756ffaf3a0bf34c766cfc1d611dba0dc4 (diff) | |
download | haskell-d20031d4c88b256cdae264cb05d9d850e973d956.tar.gz |
Add parseExpr and compileParsedExpr and use them in GHC API and GHCi
Summary:
This commit brings following changes and fixes:
* Implement parseExpr and compileParsedExpr;
* Fix compileExpr and dynCompilerExpr, which returned `()` for empty expr;
* Fix :def and :cmd, which didn't work if `IO` or `String` is not in scope;
* Use GHCiMonad instead IO in :def and :cmd;
* Clean PrelInfo: delete dead comment and duplicate entries, add assertion.
See new tests for more details.
Test Plan: ./validate
Reviewers: austin, dterei, simonmar
Reviewed By: simonmar
Subscribers: thomie, bgamari
Differential Revision: https://phabricator.haskell.org/D974
GHC Trac Issues: #10508
Diffstat (limited to 'compiler/main/GHC.hs')
-rw-r--r-- | compiler/main/GHC.hs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/main/GHC.hs b/compiler/main/GHC.hs index 39af5fa984..1a7d4ef71e 100644 --- a/compiler/main/GHC.hs +++ b/compiler/main/GHC.hs @@ -99,7 +99,7 @@ module GHC ( -- ** Get/set the current context parseImportDecl, setContext, getContext, - setGHCiMonad, + setGHCiMonad, getGHCiMonad, #endif -- ** Inspecting the current context getBindings, getInsts, getPrintUnqual, @@ -124,7 +124,8 @@ module GHC ( lookupName, #ifdef GHCI -- ** Compiling expressions - InteractiveEval.compileExpr, HValue, dynCompileExpr, + HValue, parseExpr, compileParsedExpr, + InteractiveEval.compileExpr, dynCompileExpr, -- ** Other runTcInteractive, -- Desired by some clients (Trac #8878) @@ -1457,6 +1458,10 @@ setGHCiMonad name = withSession $ \hsc_env -> do let ic = (hsc_IC s) { ic_monad = ty } in s { hsc_IC = ic } +-- | Get the monad GHCi lifts user statements into. +getGHCiMonad :: GhcMonad m => m Name +getGHCiMonad = fmap (ic_monad . hsc_IC) getSession + getHistorySpan :: GhcMonad m => History -> m SrcSpan getHistorySpan h = withSession $ \hsc_env -> return $ InteractiveEval.getHistorySpan hsc_env h |