List modules with its packages
This commit is contained in:
parent
ad0bd9d552
commit
94de367220
@ -5,6 +5,7 @@ import Data.List
|
|||||||
import GHC
|
import GHC
|
||||||
import Language.Haskell.GhcMod.GHCApi
|
import Language.Haskell.GhcMod.GHCApi
|
||||||
import Language.Haskell.GhcMod.Types
|
import Language.Haskell.GhcMod.Types
|
||||||
|
import Distribution.Text (display)
|
||||||
import Packages
|
import Packages
|
||||||
import UniqFM
|
import UniqFM
|
||||||
|
|
||||||
@ -12,14 +13,20 @@ import UniqFM
|
|||||||
|
|
||||||
-- | Listing installed modules.
|
-- | Listing installed modules.
|
||||||
listModules :: Options -> IO String
|
listModules :: Options -> IO String
|
||||||
listModules opt = convert opt . nub . sort <$> withGHCDummyFile (listMods opt)
|
listModules opt = convert opt . nub . sort . map dropPkgs <$> withGHCDummyFile (listMods opt) where
|
||||||
|
dropPkgs (name, pkg)
|
||||||
|
| detailed opt = name ++ " " ++ pkg
|
||||||
|
| otherwise = name
|
||||||
|
|
||||||
-- | Listing installed modules.
|
-- | Listing installed modules.
|
||||||
listMods :: Options -> Ghc [String]
|
listMods :: Options -> Ghc [(String, String)]
|
||||||
listMods opt = do
|
listMods opt = do
|
||||||
initializeFlags opt
|
initializeFlags opt
|
||||||
getExposedModules <$> getSessionDynFlags
|
getExposedModules <$> getSessionDynFlags
|
||||||
where
|
where
|
||||||
getExposedModules = map moduleNameString
|
getExposedModules = concatMap exposedModules'
|
||||||
. concatMap exposedModules
|
|
||||||
. eltsUFM . pkgIdMap . pkgState
|
. eltsUFM . pkgIdMap . pkgState
|
||||||
|
exposedModules' p =
|
||||||
|
map moduleNameString (exposedModules p)
|
||||||
|
`zip`
|
||||||
|
repeat (display $ sourcePackageId p)
|
||||||
|
@ -22,7 +22,7 @@ ghcOptHelp = " [-g GHC_opt1 -g GHC_opt2 ...] "
|
|||||||
usage :: String
|
usage :: String
|
||||||
usage = "ghc-mod version " ++ showVersion version ++ "\n"
|
usage = "ghc-mod version " ++ showVersion version ++ "\n"
|
||||||
++ "Usage:\n"
|
++ "Usage:\n"
|
||||||
++ "\t ghc-mod list" ++ ghcOptHelp ++ "[-l]\n"
|
++ "\t ghc-mod list" ++ ghcOptHelp ++ "[-l] [-d]\n"
|
||||||
++ "\t ghc-mod lang [-l]\n"
|
++ "\t ghc-mod lang [-l]\n"
|
||||||
++ "\t ghc-mod flag [-l]\n"
|
++ "\t ghc-mod flag [-l]\n"
|
||||||
++ "\t ghc-mod browse" ++ ghcOptHelp ++ "[-l] [-o] [-d] <module> [<module> ...]\n"
|
++ "\t ghc-mod browse" ++ ghcOptHelp ++ "[-l] [-o] [-d] <module> [<module> ...]\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user