ghc-mod/Language/Haskell/GhcMod/List.hs

26 lines
753 B
Haskell
Raw Normal View History

2013-05-20 05:28:56 +00:00
module Language.Haskell.GhcMod.List (listModules, listMods) where
2010-03-11 10:03:17 +00:00
import Control.Applicative
import Data.List
2010-04-30 09:17:20 +00:00
import GHC
2013-05-17 01:00:01 +00:00
import Language.Haskell.GhcMod.GHCApi
import Language.Haskell.GhcMod.Types
2010-04-30 09:17:20 +00:00
import Packages
import UniqFM
2010-03-11 10:03:17 +00:00
----------------------------------------------------------------
2013-05-20 05:28:56 +00:00
-- | Listing installed modules.
2013-05-20 02:29:44 +00:00
listModules :: Options -> IO String
2013-05-20 05:28:56 +00:00
listModules opt = convert opt . nub . sort <$> withGHCDummyFile (listMods opt)
2010-03-11 10:03:17 +00:00
2013-05-20 05:28:56 +00:00
-- | Listing installed modules.
listMods :: Options -> Ghc [String]
listMods opt = do
2013-03-04 04:41:56 +00:00
initializeFlags opt
2010-04-30 09:17:20 +00:00
getExposedModules <$> getSessionDynFlags
2010-03-11 10:03:17 +00:00
where
2010-04-30 09:36:31 +00:00
getExposedModules = map moduleNameString
. concatMap exposedModules
. eltsUFM . pkgIdMap . pkgState