-importContext :: Bool -> String -> GHCi ()
-importContext fail str
- = do
- (as,bs) <- GHC.getContext
- x <- do_checks fail
- case Monad.join x of
- Nothing -> return ()
- (Just a) -> do
- m <- loadModuleName a
- GHC.setContext as (bs++[(m,Just a)])
- st <- getGHCiState
- let cmds = remembered_ctx st
- setGHCiState st{ remembered_ctx = cmds++[Right str] }
- where
- do_checks True = liftM Just (GhciMonad.parseImportDecl str)
- do_checks False = trymaybe (GhciMonad.parseImportDecl str)
+newContextCmd :: CtxtCmd -> GHCi ()
+newContextCmd cmd = do
+ playCtxtCmd True cmd
+ st <- getGHCiState
+ let cmds = remembered_ctx st
+ setGHCiState st{ remembered_ctx = cmds ++ [cmd] }