From 9e238da6f0defe6397eb67603af868125fe5398f Mon Sep 17 00:00:00 2001 From: David Terei Date: Wed, 25 Jan 2012 23:49:54 -0800 Subject: Code cleaning --- compiler/main/HscMain.hs | 47 +++++++++++++-------------------------- compiler/typecheck/TcRnDriver.lhs | 2 -- 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) -- cgit v1.2.1