cleaning up APIs.
This commit is contained in:
parent
064e4af236
commit
2f55a19d49
@ -32,7 +32,7 @@ module Language.Haskell.GhcMod (
|
||||
, check
|
||||
, info
|
||||
, typeOf
|
||||
, listMods
|
||||
, modules
|
||||
, lint
|
||||
) where
|
||||
|
||||
|
@ -31,7 +31,7 @@ browseModule :: Options
|
||||
-> Cradle
|
||||
-> ModuleString -- ^ A module name. (e.g. \"Data.List\")
|
||||
-> IO String
|
||||
browseModule opt cradle mdlName = convert opt . sort <$> withGHCDummyFile (browse opt cradle mdlName)
|
||||
browseModule opt cradle mdlName = withGHCDummyFile (browse opt cradle mdlName)
|
||||
|
||||
-- | Getting functions, classes, etc from a module.
|
||||
-- If 'detailed' is 'True', their types are also obtained.
|
||||
@ -39,10 +39,10 @@ browseModule opt cradle mdlName = convert opt . sort <$> withGHCDummyFile (brows
|
||||
browse :: Options
|
||||
-> Cradle
|
||||
-> ModuleString -- ^ A module name. (e.g. \"Data.List\")
|
||||
-> Ghc [String]
|
||||
-> Ghc String
|
||||
browse opt cradle mdlName = do
|
||||
void $ initializeFlagsWithCradle opt cradle [] False
|
||||
getModule >>= G.getModuleInfo >>= listExports
|
||||
convert opt . sort <$> (getModule >>= G.getModuleInfo >>= listExports)
|
||||
where
|
||||
getModule = G.findModule mdlname mpkgid `G.gcatch` fallback
|
||||
mdlname = G.mkModuleName mdlName
|
||||
|
@ -1,4 +1,4 @@
|
||||
module Language.Haskell.GhcMod.List (listModules, listMods) where
|
||||
module Language.Haskell.GhcMod.List (listModules, modules) where
|
||||
|
||||
import Control.Applicative ((<$>))
|
||||
import Control.Monad (void)
|
||||
@ -14,17 +14,13 @@ import UniqFM (eltsUFM)
|
||||
|
||||
-- | Listing installed modules.
|
||||
listModules :: Options -> Cradle -> IO String
|
||||
listModules opt cradle = convert opt . nub . sort . map dropPkgs <$> withGHCDummyFile (listMods opt cradle)
|
||||
where
|
||||
dropPkgs (name, pkg)
|
||||
| detailed opt = name ++ " " ++ pkg
|
||||
| otherwise = name
|
||||
listModules opt cradle = withGHCDummyFile (modules opt cradle)
|
||||
|
||||
-- | Listing installed modules.
|
||||
listMods :: Options -> Cradle -> Ghc [(String, String)]
|
||||
listMods opt cradle = do
|
||||
modules :: Options -> Cradle -> Ghc String
|
||||
modules opt cradle = do
|
||||
void $ initializeFlagsWithCradle opt cradle [] False
|
||||
getExposedModules <$> G.getSessionDynFlags
|
||||
convert opt . nub . sort . map dropPkgs . getExposedModules <$> G.getSessionDynFlags
|
||||
where
|
||||
getExposedModules = concatMap exposedModules'
|
||||
. eltsUFM . pkgIdMap . G.pkgState
|
||||
@ -32,3 +28,6 @@ listMods opt cradle = do
|
||||
map G.moduleNameString (exposedModules p)
|
||||
`zip`
|
||||
repeat (display $ sourcePackageId p)
|
||||
dropPkgs (name, pkg)
|
||||
| detailed opt = name ++ " " ++ pkg
|
||||
| otherwise = name
|
||||
|
Loading…
Reference in New Issue
Block a user