2010-03-11 10:03:17 +00:00
|
|
|
module List (listModules) where
|
|
|
|
|
|
|
|
import Control.Applicative
|
|
|
|
import Data.List
|
2010-04-30 09:17:20 +00:00
|
|
|
import GHC
|
|
|
|
import Packages
|
2010-04-30 09:36:31 +00:00
|
|
|
import Types
|
2010-04-30 09:17:20 +00:00
|
|
|
import UniqFM
|
2010-03-11 10:03:17 +00:00
|
|
|
|
|
|
|
----------------------------------------------------------------
|
|
|
|
|
2010-03-11 13:39:07 +00:00
|
|
|
listModules :: Options -> IO String
|
2011-05-27 20:43:52 +00:00
|
|
|
listModules opt = convert opt . nub . sort <$> list opt
|
2010-03-11 10:03:17 +00:00
|
|
|
|
2011-05-27 20:43:52 +00:00
|
|
|
list :: Options -> IO [String]
|
|
|
|
list opt = withGHC $ do
|
|
|
|
initSession0 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
|