@@ -113,12 +113,12 @@ loadModule filename = do
113113-- |
114114-- Load all modules.
115115--
116−loadAllModules :: [FilePath] -> IO (Either P.MultipleErrors [(Either P.RebuildPolicy FilePath, P.Module)])
116+loadAllModules :: [FilePath] -> IO (Either P.MultipleErrors [(FilePath, P.Module)])
117117loadAllModules files = do
118118 filesAndContent <- forM files $ \filename -> do
119119 content <- readFile filename
120− return (Right filename, content)
121− return $ P.parseModulesFromFiles (either (const "") id) filesAndContent
120+ return (filename, content)
121+ return $ P.parseModulesFromFiles id filesAndContent
122122
123123-- |
124124-- Load all modules, updating the application state
@@ -248,13 +248,14 @@ makeIO f io = do
248248 e <- liftIO $ tryIOError io
249249 either (throwError . P.singleError . f) return e
250250
251−make :: PSCiState -> [(Either P.RebuildPolicy FilePath, P.Module)] -> P.Make P.Environment
252−make st@PSCiState{..} ms = P.make actions' (map snd (loadedModules ++ ms))
251+make :: PSCiState -> [P.Module] -> P.Make P.Environment
252+make st@PSCiState{..} ms = P.make actions' (map snd loadedModules ++ ms)
253253 where
254− filePathMap = M.fromList $ (first P.getModuleName . swap) `map` (loadedModules ++ ms)
254+ filePathMap = M.fromList $ (first P.getModuleName . swap) `map` allModules
255255 actions = P.buildMakeActions modulesDir filePathMap psciForeignFiles False
256256 actions' = actions { P.progress = const (return ()) }
257257 loadedModules = psciLoadedModules st
258+ allModules = map (first Right) loadedModules ++ map (Left P.RebuildAlways,) ms
258259
259260-- |
260261-- Takes a value declaration and evaluates it with the current state.
@@ -264,7 +265,7 @@ handleDeclaration val = do
264265 st <- PSCI $ lift get
265266 let m = createTemporaryModule True st val
266267 let nodeArgs = psciNodeFlags st ++ [indexFile]
267− e <- psciIO . runMake $ make st [(Left P.RebuildAlways, supportModule), (Left P.RebuildAlways, m)]
268+ e <- psciIO . runMake $ make st [supportModule, m]
268269 case e of
269270 Left errs -> printErrors errs
270271 Right _ -> do
@@ -285,7 +286,7 @@ handleDecls ds = do
285286 st <- PSCI $ lift get
286287 let st' = updateLets ds st
287288 let m = createTemporaryModule False st' (P.ObjectLiteral [])
288− e <- psciIO . runMake $ make st' [(Left P.RebuildAlways, m)]
289+ e <- psciIO . runMake $ make st' [m]
289290 case e of
290291 Left err -> printErrors err
291292 Right _ -> PSCI $ lift (put st')
@@ -341,7 +342,7 @@ handleImport :: ImportedModule -> PSCI ()
341342handleImport im = do
342343 st <- updateImportedModules im <$> PSCI (lift get)
343344 let m = createTemporaryModuleForImports st
344− e <- psciIO . runMake $ make st [(Left P.RebuildAlways, m)]
345+ e <- psciIO . runMake $ make st [m]
345346 case e of
346347 Left errs -> printErrors errs
347348 Right _ -> do
@@ -355,7 +356,7 @@ handleTypeOf :: P.Expr -> PSCI ()
355356handleTypeOf val = do
356357 st <- PSCI $ lift get
357358 let m = createTemporaryModule False st val
358− e <- psciIO . runMake $ make st [(Left P.RebuildAlways, m)]
359+ e <- psciIO . runMake $ make st [m]
359360 case e of
360361 Left errs -> printErrors errs
361362 Right env' ->
@@ -492,7 +493,7 @@ handleKindOf typ = do
492493 st <- PSCI $ lift get
493494 let m = createTemporaryModuleForKind st typ
494495 mName = P.ModuleName [P.ProperName "$PSCI"]
495− e <- psciIO . runMake $ make st [(Left P.RebuildAlways, m)]
496+ e <- psciIO . runMake $ make st [m]
496497 case e of
497498 Left errs -> printErrors errs
498499 Right env' ->
@@ -534,11 +535,10 @@ handleCommand ShowHelp = PSCI $ outputStrLn helpMessage
534535handleCommand (Import im) = handleImport im
535536handleCommand (Decls l) = handleDecls l
536537handleCommand (LoadFile filePath) = whenFileExists filePath $ \absPath -> do
537− PSCI . lift $ modify (updateImportedFiles absPath)
538538 m <- psciIO $ loadModule absPath
539539 case m of
540540 Left err -> PSCI $ outputStrLn err
541− Right mods -> PSCI . lift $ modify (updateModules (map ((,) (Right absPath)) mods))
541+ Right mods -> PSCI . lift $ modify (updateModules (map (absPath,) mods))
542542handleCommand (LoadForeign filePath) = whenFileExists filePath $ \absPath -> do
543543 foreignsOrError <- psciIO . runMake $ do
544544 foreignFile <- makeIO (const (P.ErrorMessage [] $ P.CannotReadFile absPath)) (readFile absPath)
@@ -549,10 +549,9 @@ handleCommand (LoadForeign filePath) = whenFileExists filePath $ \absPath -> do
549549handleCommand ResetState = do
550550 files <- psciImportedFilenames <$> PSCI (lift get)
551551 PSCI . lift . modify $ \st ->
552− (foldl (flip updateImportedFiles) st files)
553− { psciImportedModules = []
554− , psciLetBindings = []
555− }
552+ st { psciImportedModules = []
553+ , psciLetBindings = []
554+ }
556555 loadAllImportedModules
557556handleCommand (TypeOf val) = handleTypeOf val
558557handleCommand (KindOf typ) = handleKindOf typ
@@ -615,7 +614,7 @@ loop PSCiOptions{..} = do
615614 case foreignsOrError of
616615 Left errs -> putStrLn (P.prettyPrintMultipleErrors False errs) >> exitFailure
617616 Right foreigns ->
618− flip evalStateT (mkPSCiState inputFiles [] modules foreigns [] psciInputNodeFlags) . runInputT (setComplete completion settings) $ do
617+ flip evalStateT (mkPSCiState [] modules foreigns [] psciInputNodeFlags) . runInputT (setComplete completion settings) $ do
619618 outputStrLn prologueMessage
620619 traverse_ (traverse_ (runPSCI . handleCommand)) config
621620 modules' <- lift $ gets psciLoadedModules