Commit 9e238da6 authored by dterei's avatar dterei
Browse files

Code cleaning

parent cda58f7c
......@@ -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]
......
......@@ -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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment