Commit 90d70e44 authored by Simon Marlow's avatar Simon Marlow

Allow foreign import declarations to the entered interactively in GHCi.

parent 25de0abf
......@@ -83,6 +83,7 @@ import VarSet
import VarEnv ( emptyTidyEnv )
import Panic
import Class
import Data.List
#endif
import Id
......@@ -145,7 +146,7 @@ import Bag
import Exception
import Control.Monad
import Data.Maybe ( catMaybes )
import Data.Maybe
import Data.IORef
\end{code}
#include "HsVersions.h"
......@@ -1364,16 +1365,26 @@ hscDeclsWithLocation hsc_env str source linenumber = runHsc hsc_env $ do
let
tcs = filter (not . isImplicitTyCon) $ mg_tcs simpl_mg
clss = mg_clss simpl_mg
tythings = map ATyCon tcs ++ map (ATyCon . classTyCon) clss
sys_vars = filter (isExternalName . idName) $
ext_vars = filter (isExternalName . idName) $
bindersOfBinds (cg_binds tidy_cg)
(sys_vars, user_vars) = partition is_sys_var ext_vars
is_sys_var id = isDFunId id
|| isRecordSelector id
|| isJust (isClassOpId_maybe id)
-- we only need to keep around the external bindings
-- (as decided by TidyPgm), since those are the only ones
-- that might be referenced elsewhere.
tythings = map AnId user_vars
++ map ATyCon tcs
++ map (ATyCon . classTyCon) clss
-- pprTrace "new tycons" (ppr tcs) $ return ()
-- pprTrace "new classes" (ppr clss) $ return ()
-- pprTrace "new sys Ids" (ppr sys_vars) $ return ()
-- pprTrace "new user Ids" (ppr user_vars) $ return ()
let ictxt1 = extendInteractiveContext icontext tythings
ictxt = ictxt1 {
......
......@@ -728,7 +728,8 @@ enqueueCommands cmds = do
-- | If we one of these strings prefixes a command, then we treat it as a decl
-- rather than a stmt.
declPrefixes :: [String]
declPrefixes = ["class ","data ","newtype ","type ","instance ", "deriving "]
declPrefixes = ["class ","data ","newtype ","type ","instance ", "deriving ",
"foreign "]
runStmt :: String -> SingleStep -> GHCi Bool
runStmt stmt step
......
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