@@ -141,6 +141,16 @@ loadAllModules files = do
141 return (Right filename, content)
141 return (Right filename, content)
142 return $ P.parseModulesFromFiles (either (const "") id) $ (Left P.RebuildNever, P.prelude) : filesAndContent
142 return $ P.parseModulesFromFiles (either (const "") id) $ (Left P.RebuildNever, P.prelude) : filesAndContent
145+-- Load all modules, updating the application state
147+loadAllImportedModules :: PSCI ()
148+loadAllImportedModules = do
149+ files <- PSCI . lift $ fmap psciImportedFilenames get
150+ modulesOrFirstError <- psciIO $ loadAllModules files
151+ case modulesOrFirstError of
152+ Left err -> psciIO $ print err
153+ Right modules -> PSCI . lift . modify $ \st -> st { psciLoadedModules = modules }
146-- Expands tilde in path.
156-- Expands tilde in path.
@@ -561,10 +571,12 @@ handleCommand (LoadFile filePath) = do
561 PSCI . outputStrLn $ "Couldn't locate: " ++ filePath
571 PSCI . outputStrLn $ "Couldn't locate: " ++ filePath
562handleCommand Reset = do
572handleCommand Reset = do
563 files <- psciImportedFilenames <$> PSCI (lift get)
573 files <- psciImportedFilenames <$> PSCI (lift get)
564− modulesOrFirstError <- psciIO $ loadAllModules files
574+ PSCI . lift . modify $ \st -> st
565− case modulesOrFirstError of
575+ { psciImportedFilenames = files
566− Left err -> psciIO $ print err >> exitFailure
576+ , psciImportedModuleNames = defaultImports
567− Right modules -> PSCI . lift $ put (PSCiState files defaultImports modules [])
577+ , psciLetBindings = []
579+ loadAllImportedModules
568handleCommand (TypeOf val) = handleTypeOf val
580handleCommand (TypeOf val) = handleTypeOf val
569handleCommand (KindOf typ) = handleKindOf typ
581handleCommand (KindOf typ) = handleKindOf typ
570handleCommand (Browse moduleName) = handleBrowse moduleName
582handleCommand (Browse moduleName) = handleBrowse moduleName
@@ -609,7 +621,7 @@ loop (PSCiOptions singleLineMode files) = do
609 Left err -> outputStrLn err >> go
621 Left err -> outputStrLn err >> go
610 Right Nothing -> go
622 Right Nothing -> go
611 Right (Just Quit) -> outputStrLn quitMessage
623 Right (Just Quit) -> outputStrLn quitMessage
612− Right (Just c') -> runPSCI (handleCommand c') >> go
624+ Right (Just c') -> runPSCI (loadAllImportedModules >> handleCommand c') >> go
614singleLineFlag :: Parser Bool
626singleLineFlag :: Parser Bool
615singleLineFlag = switch $
627singleLineFlag = switch $