2014-08-28 09:41:03 +00:00
|
|
|
module Language.Haskell.GhcMod.Modules (modules) where
|
2010-03-11 10:03:17 +00:00
|
|
|
|
2015-03-05 17:54:39 +00:00
|
|
|
import Control.Arrow
|
|
|
|
import Data.List
|
2014-05-11 22:40:00 +00:00
|
|
|
import Language.Haskell.GhcMod.Convert
|
2015-03-05 17:54:39 +00:00
|
|
|
import Language.Haskell.GhcMod.Types
|
2014-07-17 05:30:42 +00:00
|
|
|
import Language.Haskell.GhcMod.Monad
|
2015-03-05 17:54:39 +00:00
|
|
|
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.
|
2015-12-07 16:57:33 +00:00
|
|
|
modules :: (IOish m, Gm m)
|
|
|
|
=> Bool -- ^ 'detailed', if 'True', also prints packages that modules belong to.
|
|
|
|
-> m String
|
2015-12-05 20:55:12 +00:00
|
|
|
modules detailed = do
|
2015-03-05 17:54:39 +00:00
|
|
|
df <- runGmPkgGhc G.getSessionDynFlags
|
|
|
|
let mns = listVisibleModuleNames df
|
|
|
|
pmnss = map (first moduleNameString) $ zip mns (modulePkg df `map` mns)
|
2015-12-05 20:55:12 +00:00
|
|
|
convert' $ nub [ if detailed then pkg ++ " " ++ mn else mn
|
2015-03-05 17:54:39 +00:00
|
|
|
| (mn, pkgs) <- pmnss, pkg <- pkgs ]
|
|
|
|
where
|
|
|
|
modulePkg df = lookupModulePackageInAllPackages df
|