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