Migrate the remaining parts of the exposed API to GhcMod a
This commit is contained in:
@@ -1,55 +1,44 @@
|
||||
module Language.Haskell.GhcMod.Debug (debugInfo, rootInfo) where
|
||||
|
||||
import Control.Applicative ((<$>))
|
||||
import Control.Exception.IOChoice ((||>))
|
||||
import CoreMonad (liftIO)
|
||||
import Data.List (intercalate)
|
||||
import Data.Maybe (fromMaybe, isJust, fromJust)
|
||||
import Data.Maybe (isJust, fromJust)
|
||||
import Language.Haskell.GhcMod.CabalApi
|
||||
import Language.Haskell.GhcMod.GHCApi
|
||||
import Language.Haskell.GhcMod.GHCChoice ((||>))
|
||||
import Language.Haskell.GhcMod.Convert
|
||||
import Language.Haskell.GhcMod.Monad
|
||||
import Language.Haskell.GhcMod.Types
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
-- | Obtaining debug information.
|
||||
debugInfo :: Options
|
||||
-> Cradle
|
||||
-> IO String
|
||||
debugInfo opt cradle = convert opt <$> do
|
||||
debugInfo :: GhcMod String
|
||||
debugInfo = cradle >>= \c -> convert' =<< do
|
||||
CompilerOptions gopts incDir pkgs <-
|
||||
if cabal then
|
||||
liftIO (fromCabalFile ||> return simpleCompilerOption)
|
||||
if isJust $ cradleCabalFile c then
|
||||
(fromCabalFile c ||> simpleCompilerOption)
|
||||
else
|
||||
return simpleCompilerOption
|
||||
mglibdir <- liftIO getSystemLibDir
|
||||
simpleCompilerOption
|
||||
return [
|
||||
"Root directory: " ++ rootDir
|
||||
, "Current directory: " ++ currentDir
|
||||
, "Cabal file: " ++ cabalFile
|
||||
"Root directory: " ++ cradleRootDir c
|
||||
, "Current directory: " ++ cradleCurrentDir c
|
||||
, "Cabal file: " ++ show (cradleCabalFile c)
|
||||
, "GHC options: " ++ unwords gopts
|
||||
, "Include directories: " ++ unwords incDir
|
||||
, "Dependent packages: " ++ intercalate ", " (map showPkg pkgs)
|
||||
, "System libraries: " ++ fromMaybe "" mglibdir
|
||||
, "System libraries: " ++ systemLibDir
|
||||
]
|
||||
where
|
||||
currentDir = cradleCurrentDir cradle
|
||||
mCabalFile = cradleCabalFile cradle
|
||||
rootDir = cradleRootDir cradle
|
||||
cabal = isJust mCabalFile
|
||||
cabalFile = fromMaybe "" mCabalFile
|
||||
origGopts = ghcOpts opt
|
||||
simpleCompilerOption = CompilerOptions origGopts [] []
|
||||
fromCabalFile = do
|
||||
pkgDesc <- parseCabalFile file
|
||||
getCompilerOptions origGopts cradle pkgDesc
|
||||
where
|
||||
file = fromJust mCabalFile
|
||||
simpleCompilerOption = options >>= \op ->
|
||||
return $ CompilerOptions (ghcOpts op) [] []
|
||||
fromCabalFile c = options >>= \opts -> liftIO $ do
|
||||
pkgDesc <- parseCabalFile $ fromJust $ cradleCabalFile c
|
||||
getCompilerOptions (ghcOpts opts) c pkgDesc
|
||||
|
||||
----------------------------------------------------------------
|
||||
|
||||
-- | Obtaining root information.
|
||||
rootInfo :: Options
|
||||
-> Cradle
|
||||
-> IO String
|
||||
rootInfo opt cradle = return $ convert opt $ cradleRootDir cradle
|
||||
rootInfo :: GhcMod String
|
||||
rootInfo = convert' =<< cradleRootDir <$> cradle
|
||||
|
||||
Reference in New Issue
Block a user