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

27 lines
922 B
Haskell
Raw Normal View History

2014-08-28 09:41:03 +00:00
module Language.Haskell.GhcMod.Modules (modules) where
2010-03-11 10:03:17 +00:00
import Control.Arrow
import Data.List
2014-05-11 22:40:00 +00:00
import Language.Haskell.GhcMod.Convert
import Language.Haskell.GhcMod.Types
2014-07-17 05:30:42 +00:00
import Language.Haskell.GhcMod.Monad
import Language.Haskell.GhcMod.Gap ( listVisibleModuleNames
, lookupModulePackageInAllPackages
)
import qualified GHC as G
2010-03-11 10:03:17 +00:00
----------------------------------------------------------------
2013-05-20 05:28:56 +00:00
-- | Listing installed modules.
modules :: (IOish m, GmEnv m) => m String
modules = do
Options { detailed } <- options
df <- runGmPkgGhc G.getSessionDynFlags
let mns = listVisibleModuleNames df
pmnss = map (first moduleNameString) $ zip mns (modulePkg df `map` mns)
convert' $ nub [ if detailed then pkg ++ " " ++ mn else mn
| (mn, pkgs) <- pmnss, pkg <- pkgs ]
where
modulePkg df = lookupModulePackageInAllPackages df