deleting GhcMod.Ghc.

This commit is contained in:
Kazu Yamamoto 2014-07-17 14:04:28 +09:00
parent 409bc99f10
commit 74e84e89ac
6 changed files with 21 additions and 20 deletions

View File

@ -13,6 +13,8 @@ module Language.Haskell.GhcMod (
, ModuleString
, Expression
, GhcPkgDb
, Symbol
, SymbolDb
-- * 'GhcMod' utilities
, boot
, browse
@ -21,6 +23,7 @@ module Language.Haskell.GhcMod (
, debugInfo
, expandTemplate
, findSymbol
, dumpSymbol
, info
, lint
, pkgDoc
@ -31,6 +34,9 @@ module Language.Haskell.GhcMod (
, modules
, languages
, flags
-- * SymbolDb
, loadSymbolDb
, lookupSymbol
) where
import Language.Haskell.GhcMod.Boot

View File

@ -3,7 +3,7 @@
module Language.Haskell.GhcMod.Find (
Symbol
, SymbolDb
, getSymbolDb
, loadSymbolDb
, lookupSymbol
, dumpSymbol
, findSymbol
@ -44,10 +44,10 @@ import qualified Data.Map as M
----------------------------------------------------------------
-- | Type of key for `SymbolDb`.
-- | Type of function and operation names.
type Symbol = String
type Db = Map Symbol [ModuleString]
-- | Database from 'Symbol' to modules.
-- | Database from 'Symbol' to \['ModuleString'\].
newtype SymbolDb = SymbolDb Db
----------------------------------------------------------------
@ -65,23 +65,24 @@ packageConfDir = "package.conf.d"
-- | Finding modules to which the symbol belong.
findSymbol :: IOish m => Symbol -> GhcModT m String
findSymbol sym = convert' =<< lookupSymbol' sym <$> liftIO getSymbolDb
findSymbol sym = convert' =<< lookupSymbol' sym <$> liftIO loadSymbolDb
lookupSymbol' :: Symbol -> SymbolDb -> [ModuleString]
lookupSymbol' sym (SymbolDb db) = fromMaybe [] (M.lookup sym db)
-- | Looking up 'SymbolDb' with 'Symbol' to find modules.
-- | Looking up 'SymbolDb' with 'Symbol' to \['ModuleString'\]
-- which will be concatenated.
lookupSymbol :: Options -> Symbol -> SymbolDb -> String
lookupSymbol opt sym db = convert opt $ lookupSymbol' sym db
---------------------------------------------------------------
-- | Creating 'SymbolDb'.
getSymbolDb :: IO SymbolDb
getSymbolDb = SymbolDb <$> loadSymbolDb
-- | Loading a file and creates 'SymbolDb'.
loadSymbolDb :: IO SymbolDb
loadSymbolDb = SymbolDb <$> readSymbolDb
loadSymbolDb :: IO Db
loadSymbolDb = handle (\(SomeException _) -> return M.empty) $ do
readSymbolDb :: IO Db
readSymbolDb = handle (\(SomeException _) -> return M.empty) $ do
file <- chop <$> readProcess "ghc-mod" ["dumpsym"] []
M.fromAscList . map conv . lines <$> readFile file
where
@ -101,6 +102,9 @@ getPath = do
[] -> return Nothing
u:_ -> liftIO $ resolvePackageDb df u
-- | Dumping a set of ('Symbol',\['ModuleString'\]) to a file
-- if the file does not exist or is invalid.
-- The file name is printed.
dumpSymbol :: IOish m => GhcModT m String
dumpSymbol = do
mdir <- getPath

View File

@ -1,6 +0,0 @@
module Language.Haskell.GhcMod.Ghc (
-- * 'SymMdlDb'
module Language.Haskell.GhcMod.Find
) where
import Language.Haskell.GhcMod.Find

View File

@ -53,7 +53,6 @@ Library
GHC-Options: -Wall
Default-Extensions: ConstraintKinds, FlexibleContexts
Exposed-Modules: Language.Haskell.GhcMod
Language.Haskell.GhcMod.Ghc
Language.Haskell.GhcMod.Monad
Language.Haskell.GhcMod.Internal
Other-Modules: Language.Haskell.GhcMod.Boot

View File

@ -10,7 +10,6 @@ import qualified Control.Exception as E
import Data.Typeable (Typeable)
import Data.Version (showVersion)
import Language.Haskell.GhcMod
import Language.Haskell.GhcMod.Ghc
import Language.Haskell.GhcMod.Monad
import Paths_ghc_mod
import System.Console.GetOpt (OptDescr(..), ArgDescr(..), ArgOrder(..))

View File

@ -34,7 +34,6 @@ import Data.Version (showVersion)
import GHC (GhcMonad)
import qualified GHC as G
import Language.Haskell.GhcMod
import Language.Haskell.GhcMod.Ghc
import Language.Haskell.GhcMod.Monad
import Paths_ghc_mod
import System.Console.GetOpt
@ -116,7 +115,7 @@ replace (x:xs) = x : replace xs
----------------------------------------------------------------
setupDB :: MVar SymbolDb -> IO ()
setupDB mvar = getSymbolDb >>= putMVar mvar
setupDB mvar = loadSymbolDb >>= putMVar mvar
----------------------------------------------------------------