summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Terei <davidterei@gmail.com>2012-01-25 23:49:54 -0800
committerDavid Terei <davidterei@gmail.com>2012-01-25 23:50:35 -0800
commit9e238da6f0defe6397eb67603af868125fe5398f (patch)
tree030fffed68149083b89e8f9ec6baeb462dbbdab2
parentcda58f7c7d87a5c13070d2a1bebe1628a7a6e9bb (diff)
downloadhaskell-9e238da6f0defe6397eb67603af868125fe5398f.tar.gz
Code cleaning
-rw-r--r--compiler/main/HscMain.hs47
-rw-r--r--compiler/typecheck/TcRnDriver.lhs2
2 files changed, 15 insertions, 34 deletions
diff --git a/compiler/main/HscMain.hs b/compiler/main/HscMain.hs
index 6f670e77b2..e06e6fa8d3 100644
--- a/compiler/main/HscMain.hs
+++ b/compiler/main/HscMain.hs
@@ -1351,31 +1351,12 @@ myCoreToStg dflags this_mod prepd_binds = do
%********************************************************************* -}
{-
-When the UnlinkedBCOExpr is linked you get an HValue of type
- IO [HValue]
-When you run it you get a list of HValues that should be
-the same length as the list of names; add them to the ClosureEnv.
+When the UnlinkedBCOExpr is linked you get an HValue of type *IO [HValue]* When
+you run it you get a list of HValues that should be the same length as the list
+of names; add them to the ClosureEnv.
-A naked expression returns a singleton Name [it].
-
- What you type The IO [HValue] that hscStmt returns
- ------------- ------------------------------------
- let pat = expr ==> let pat = expr in return [coerce HVal x, coerce HVal y, ...]
- bindings: [x,y,...]
-
- pat <- expr ==> expr >>= \ pat -> return [coerce HVal x, coerce HVal y, ...]
- bindings: [x,y,...]
-
- expr (of IO type) ==> expr >>= \ v -> return [v]
- [NB: result not printed] bindings: [it]
-
-
- expr (of non-IO type,
- result showable) ==> let v = expr in print v >> return [v]
- bindings: [it]
-
- expr (of non-IO type,
- result not showable) ==> error
+A naked expression returns a singleton Name [it]. The stmt is lifted into the
+IO monad as explained in Note [Interactively-bound Ids in GHCi] in TcRnDriver
-}
#ifdef GHCI
@@ -1400,21 +1381,23 @@ hscStmtWithLocation hsc_env stmt source linenumber = runHsc hsc_env $ do
case maybe_stmt of
Nothing -> return Nothing
- -- The real stuff
Just parsed_stmt -> do
- -- Rename and typecheck it
- let icontext = hsc_IC hsc_env
- (ids, tc_expr) <- ioMsgMaybe $
- tcRnStmt hsc_env icontext parsed_stmt
+ let icntxt = hsc_IC hsc_env
+ rdr_env = ic_rn_gbl_env icntxt
+ type_env = mkTypeEnvWithImplicits (ic_tythings icntxt)
+ src_span = srcLocSpan interactiveSrcLoc
+
+ -- Rename and typecheck it
+ -- Here we lift the stmt into the IO monad, see Note
+ -- [Interactively-bound Ids in GHCi] in TcRnDriver
+ (ids, tc_expr) <- ioMsgMaybe $ tcRnStmt hsc_env icntxt parsed_stmt
+
-- Desugar it
- let rdr_env = ic_rn_gbl_env icontext
- type_env = mkTypeEnvWithImplicits (ic_tythings icontext)
ds_expr <- ioMsgMaybe $
deSugarExpr hsc_env iNTERACTIVE rdr_env type_env tc_expr
handleWarnings
-- Then code-gen, and link it
- let src_span = srcLocSpan interactiveSrcLoc
hsc_env <- getHscEnv
hval <- liftIO $ hscCompileCoreExpr hsc_env src_span ds_expr
let hval_io = unsafeCoerce# hval :: IO [HValue]
diff --git a/compiler/typecheck/TcRnDriver.lhs b/compiler/typecheck/TcRnDriver.lhs
index 5d81de0168..6f7e68af1b 100644
--- a/compiler/typecheck/TcRnDriver.lhs
+++ b/compiler/typecheck/TcRnDriver.lhs
@@ -1240,7 +1240,6 @@ The Ids bound by previous Stmts in GHCi are currently
to look at them, and :info expects the things it looks up to have
tidy types
-
--------------------------------------------------------------------------
Typechecking Stmts in GHCi
@@ -1263,7 +1262,6 @@ Here is the grand plan, implemented in tcUserStmt
expr (of non-IO type,
result not showable) ==> error
-
\begin{code}
type PlanResult = ([Id], LHsExpr Id)