diff --git a/Language/Haskell/GhcMod/List.hs b/Language/Haskell/GhcMod/List.hs index 2d360d9..311d02b 100644 --- a/Language/Haskell/GhcMod/List.hs +++ b/Language/Haskell/GhcMod/List.hs @@ -1,6 +1,7 @@ module Language.Haskell.GhcMod.List (listModules, listMods) where import Control.Applicative +import Control.Monad (void) import Data.List import GHC import Language.Haskell.GhcMod.GHCApi @@ -11,13 +12,13 @@ import UniqFM ---------------------------------------------------------------- -- | Listing installed modules. -listModules :: Options -> IO String -listModules opt = convert opt . nub . sort <$> withGHCDummyFile (listMods opt) +listModules :: Options -> Cradle -> IO String +listModules opt cradle = convert opt . nub . sort <$> withGHCDummyFile (listMods opt cradle) -- | Listing installed modules. -listMods :: Options -> Ghc [String] -listMods opt = do - initializeFlags opt +listMods :: Options -> Cradle -> Ghc [String] +listMods opt cradle = do + void $ initializeFlagsWithCradle opt cradle [] False getExposedModules <$> getSessionDynFlags where getExposedModules = map moduleNameString diff --git a/src/GHCMod.hs b/src/GHCMod.hs index 82e8c51..9d159e0 100644 --- a/src/GHCMod.hs +++ b/src/GHCMod.hs @@ -97,7 +97,7 @@ main = flip catches handlers $ do else throw (TooManyArguments cmdArg0) res <- case cmdArg0 of "browse" -> concat <$> mapM (browseModule opt) remainingArgs - "list" -> listModules opt + "list" -> listModules opt cradle "check" -> checkSyntax opt cradle remainingArgs "expand" -> checkSyntax opt { expandSplice = True } cradle remainingArgs "debug" -> nArgs 1 $ debugInfo opt cradle cmdArg1 @@ -107,7 +107,7 @@ main = flip catches handlers $ do "lang" -> listLanguages opt "flag" -> listFlags opt "boot" -> do - mods <- listModules opt + mods <- listModules opt cradle langs <- listLanguages opt flags <- listFlags opt pre <- concat <$> mapM (browseModule opt) preBrowsedModules diff --git a/test/ListSpec.hs b/test/ListSpec.hs index b952529..98ca0ef 100644 --- a/test/ListSpec.hs +++ b/test/ListSpec.hs @@ -8,5 +8,6 @@ spec :: Spec spec = do describe "listModules" $ do it "lists up module names" $ do - modules <- lines <$> listModules defaultOptions + cradle <- findCradle + modules <- lines <$> listModules defaultOptions cradle modules `shouldContain` ["Data.Map"]