From ba717470fba3d618a4812e23a738bf9e2c244378 Mon Sep 17 00:00:00 2001 From: Luigy Leon Date: Tue, 8 Mar 2016 12:30:28 -0500 Subject: [PATCH] improve ghci results after :load Main module collision with main filepath --- src/Stack/Ghci.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Stack/Ghci.hs b/src/Stack/Ghci.hs index 7cf6c9b79d..22eb985e6d 100644 --- a/src/Stack/Ghci.hs +++ b/src/Stack/Ghci.hs @@ -133,10 +133,9 @@ ghci opts@GhciOpts{..} = do T.unwords (map T.pack (nubOrd omittedOpts))) allModules <- checkForDuplicateModules ghciNoLoadModules pkgs oiDir <- objectInterfaceDir bconfig - (modulesToLoad, thingsToLoad) <- if ghciNoLoadModules then return ([], []) else do + (modulesToLoad, mainFile) <- if ghciNoLoadModules then return ([], Nothing) else do mainFile <- figureOutMainFile bopts mainIsTargets targets pkgs - let thingsToLoad = maybe [] (return . toFilePath) mainFile <> allModules - return (allModules, thingsToLoad) + return (allModules, mainFile) let odir = [ "-odir=" <> toFilePathNoTrailingSep oiDir , "-hidir=" <> toFilePathNoTrailingSep oiDir ] @@ -160,9 +159,10 @@ ghci opts@GhciOpts{..} = do else do let scriptPath = tmpDir $(mkRelFile "ghci-script") fp = toFilePath scriptPath - loadModules = ":load " <> unwords (map show thingsToLoad) + loadModules = ":load " <> unwords (map show modulesToLoad) + addMainFile = maybe "" ((":add " <>) . toFilePath) mainFile bringIntoScope = ":module + " <> unwords modulesToLoad - liftIO (writeFile fp (unlines [loadModules,bringIntoScope])) + liftIO (writeFile fp (unlines [loadModules,addMainFile,bringIntoScope])) setScriptPerms fp execGhci (macrosOpts ++ ["-ghci-script=" <> fp])