diff options
author | David Terei <davidterei@gmail.com> | 2012-02-09 03:45:24 -0800 |
---|---|---|
committer | David Terei <davidterei@gmail.com> | 2012-02-10 10:35:29 -0800 |
commit | 5e9e07a33e17da01245f0cea78e6a6f8a32ac77d (patch) | |
tree | 82f6e3c524f8b1d0085135bfc7748dea68946dcd /ghc | |
parent | e5272d9bf2a65b7da8364803fcafbd2012b7de97 (diff) | |
download | haskell-5e9e07a33e17da01245f0cea78e6a6f8a32ac77d.tar.gz |
Have :load work under -XSafe in GHCi.
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/InteractiveUI.hs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs index 8d0205d846..3d0adacf6b 100644 --- a/ghc/InteractiveUI.hs +++ b/ghc/InteractiveUI.hs @@ -1655,7 +1655,9 @@ checkAdd :: Bool -> String -> GHCi (InteractiveImport) checkAdd star mstr = do dflags <- getDynFlags case safeLanguageOn dflags of - True | star -> ghcError $ CmdLineError "can't use * imports with Safe Haskell" + True | star -> do + liftIO $ putStrLn "Warning: can't use * imports with Safe Haskell; ignoring *" + checkAdd False mstr True -> do m <- lookupModule mstr s <- GHC.isModuleTrusted m @@ -1685,8 +1687,8 @@ checkAdd star mstr = do setGHCContextFromGHCiState :: GHCi () setGHCContextFromGHCiState = do st <- getGHCiState - goodTran <- filterM (tryBool . ok) $ transient_ctx st - goodRemb <- filterM (tryBool . ok) $ remembered_ctx st + goodTran <- mapMaybeM (tryBool . ok) $ transient_ctx st + goodRemb <- mapMaybeM (tryBool . ok) $ remembered_ctx st -- drop bad imports so we don't keep replaying it to the user! modifyGHCiState $ \s -> s { transient_ctx = goodTran } modifyGHCiState $ \s -> s { remembered_ctx = goodRemb } @@ -1696,6 +1698,8 @@ setGHCContextFromGHCiState = do ok (IIModule m) = checkAdd True (moduleNameString (moduleName m)) ok (IIDecl d) = checkAdd False (moduleNameString (unLoc (ideclName d))) + mapMaybeM f xs = catMaybes `fmap` sequence (map f xs) + setContext :: [String] -> [String] -> GHCi () setContext starred not_starred = do is1 <- mapM (checkAdd True) starred @@ -2752,12 +2756,12 @@ ghciHandle h m = Haskeline.catch m $ \e -> unblock (h e) ghciTry :: GHCi a -> GHCi (Either SomeException a) ghciTry (GHCi m) = GHCi $ \s -> gtry (m s) -tryBool :: GHCi a -> GHCi Bool +tryBool :: GHCi a -> GHCi (Maybe a) tryBool m = do r <- ghciTry m case r of - Left e -> showException e >> return False - Right _ -> return True + Left e -> showException e >> return Nothing + Right a -> return $ Just a -- ---------------------------------------------------------------------------- -- Utils |