summaryrefslogtreecommitdiff
path: root/compiler/main/InteractiveEval.hs
diff options
context:
space:
mode:
authorIavor S. Diatchki <iavor.diatchki@gmail.com>2012-02-12 13:29:29 -0800
committerIavor S. Diatchki <iavor.diatchki@gmail.com>2012-02-12 13:29:29 -0800
commitcfd89e12334e7dbcc8d9aaee898bcc38b77f549b (patch)
tree44510e960a6ac31c88219010052ea9b2e5d7217d /compiler/main/InteractiveEval.hs
parent5851f84733f4ef1ee158b911febd753ced619555 (diff)
parent86ebfef9a5acc60b7a2ce3c8f025e6e707f17f87 (diff)
downloadhaskell-cfd89e12334e7dbcc8d9aaee898bcc38b77f549b.tar.gz
Merge remote-tracking branch 'origin/master' into type-nats
Conflicts: compiler/coreSyn/CoreLint.lhs
Diffstat (limited to 'compiler/main/InteractiveEval.hs')
-rw-r--r--compiler/main/InteractiveEval.hs21
1 files changed, 10 insertions, 11 deletions
diff --git a/compiler/main/InteractiveEval.hs b/compiler/main/InteractiveEval.hs
index eee5c00255..cdc2ca501a 100644
--- a/compiler/main/InteractiveEval.hs
+++ b/compiler/main/InteractiveEval.hs
@@ -198,17 +198,18 @@ runStmtWithLocation source linenumber expr step =
let dflags' = wopt_unset (hsc_dflags hsc_env) Opt_WarnUnusedBinds
hsc_env' = hsc_env{ hsc_dflags = dflags' }
+ -- compile to value (IO [HValue]), don't run
r <- liftIO $ hscStmtWithLocation hsc_env' expr source linenumber
case r of
- Nothing -> return (RunOk []) -- empty statement / comment
+ -- empty statement / comment
+ Nothing -> return (RunOk [])
Just (tyThings, hval) -> do
status <-
withVirtualCWD $
withBreakAction (isStep step) dflags' breakMVar statusMVar $ do
- let thing_to_run = unsafeCoerce# hval :: IO [HValue]
- liftIO $ sandboxIO dflags' statusMVar thing_to_run
+ liftIO $ sandboxIO dflags' statusMVar hval
let ic = hsc_IC hsc_env
bindings = (ic_tythings ic, ic_rn_gbl_env ic)
@@ -942,20 +943,18 @@ typeKind normalise str = withSession $ \hsc_env -> do
liftIO $ hscKcType hsc_env normalise str
-----------------------------------------------------------------------------
--- cmCompileExpr: compile an expression and deliver an HValue
+-- Compile an expression, run it and deliver the resulting HValue
compileExpr :: GhcMonad m => String -> m HValue
compileExpr expr = withSession $ \hsc_env -> do
Just (ids, hval) <- liftIO $ hscStmt hsc_env ("let __cmCompileExpr = "++expr)
- -- Run it!
- hvals <- liftIO (unsafeCoerce# hval :: IO [HValue])
-
+ hvals <- liftIO hval
case (ids,hvals) of
([_],[hv]) -> return hv
- _ -> panic "compileExpr"
+ _ -> panic "compileExpr"
-- -----------------------------------------------------------------------------
--- Compile an expression into a dynamic
+-- Compile an expression, run it and return the result as a dynamic
dynCompileExpr :: GhcMonad m => String -> m Dynamic
dynCompileExpr expr = do
@@ -977,8 +976,8 @@ dynCompileExpr expr = do
setContext iis
vals <- liftIO (unsafeCoerce# hvals :: IO [Dynamic])
case (ids,vals) of
- (_:[], v:[]) -> return v
- _ -> panic "dynCompileExpr"
+ (_:[], v:[]) -> return v
+ _ -> panic "dynCompileExpr"
-----------------------------------------------------------------------------
-- show a module and it's source/object filenames