git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Fix #796. Rebuild modules before each command is executed.
commit9dc0095ccc2a0c124e792d873d845d859186f2eb authorPhil Freeman <paf31@cantab.net> dateTue 10 Feb 2015, 11:28 (12 years ago) parenta49ab17
1 file changed+17−5
psci/Main.hs+17−5
psci/Main.hs+17−5
@@ -141,6 +141,16 @@ loadAllModules files = do
141141 return (Right filename, content)
142142 return $ P.parseModulesFromFiles (either (const "") id) $ (Left P.RebuildNever, P.prelude) : filesAndContent
143143
144+-- |
145+-- Load all modules, updating the application state
146+--
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 }
144154
145155-- |
146156-- Expands tilde in path.
@@ -561,10 +571,12 @@ handleCommand (LoadFile filePath) = do
561571 PSCI . outputStrLn $ "Couldn't locate: " ++ filePath
562572handleCommand Reset = do
563573 files <- psciImportedFilenames <$> PSCI (lift get)
564− modulesOrFirstError <- psciIO $ loadAllModules files
565− case modulesOrFirstError of
566− Left err -> psciIO $ print err >> exitFailure
567− Right modules -> PSCI . lift $ put (PSCiState files defaultImports modules [])
574+ PSCI . lift . modify $ \st -> st
575+ { psciImportedFilenames = files
576+ , psciImportedModuleNames = defaultImports
577+ , psciLetBindings = []
578+ }
579+ loadAllImportedModules
568580handleCommand (TypeOf val) = handleTypeOf val
569581handleCommand (KindOf typ) = handleKindOf typ
570582handleCommand (Browse moduleName) = handleBrowse moduleName
@@ -609,7 +621,7 @@ loop (PSCiOptions singleLineMode files) = do
609621 Left err -> outputStrLn err >> go
610622 Right Nothing -> go
611623 Right (Just Quit) -> outputStrLn quitMessage
612− Right (Just c') -> runPSCI (handleCommand c') >> go
624+ Right (Just c') -> runPSCI (loadAllImportedModules >> handleCommand c') >> go
613625
614626singleLineFlag :: Parser Bool
615627singleLineFlag = switch $