Files
ghc-mod/Language/Haskell/GhcMod/Debug.hs

56 lines
1.8 KiB
Haskell
Raw Normal View History

2014-04-21 11:31:15 +09:00
module Language.Haskell.GhcMod.Debug (debugInfo, rootInfo) where
2013-03-04 11:21:41 +09:00
2014-03-27 15:23:27 +09:00
import Control.Applicative ((<$>))
import Control.Exception.IOChoice ((||>))
2014-03-27 15:08:07 +09:00
import CoreMonad (liftIO)
2013-03-04 11:21:41 +09:00
import Data.List (intercalate)
2014-03-27 15:23:27 +09:00
import Data.Maybe (fromMaybe, isJust, fromJust)
2013-05-17 10:00:01 +09:00
import Language.Haskell.GhcMod.CabalApi
import Language.Haskell.GhcMod.GHCApi
2014-05-12 00:40:00 +02:00
import Language.Haskell.GhcMod.Convert
2013-05-17 10:00:01 +09:00
import Language.Haskell.GhcMod.Types
2013-03-04 11:21:41 +09:00
----------------------------------------------------------------
2013-05-20 14:28:56 +09:00
-- | Obtaining debug information.
debugInfo :: Options
-> Cradle
-> IO String
2014-04-21 11:31:15 +09:00
debugInfo opt cradle = convert opt <$> do
2013-09-19 15:58:50 +09:00
CompilerOptions gopts incDir pkgs <-
2013-03-04 11:21:41 +09:00
if cabal then
2013-09-19 16:21:48 +09:00
liftIO (fromCabalFile ||> return simpleCompilerOption)
2013-03-04 11:21:41 +09:00
else
2013-09-19 16:21:48 +09:00
return simpleCompilerOption
2014-04-16 11:52:49 +09:00
mglibdir <- liftIO getSystemLibDir
2013-03-04 11:21:41 +09:00
return [
2014-03-19 15:01:32 +09:00
"Root directory: " ++ rootDir
, "Current directory: " ++ currentDir
2013-03-04 11:21:41 +09:00
, "Cabal file: " ++ cabalFile
2013-03-05 16:57:18 +09:00
, "GHC options: " ++ unwords gopts
, "Include directories: " ++ unwords incDir
, "Dependent packages: " ++ intercalate ", " (map showPkg pkgs)
2014-04-09 15:15:26 +09:00
, "System libraries: " ++ fromMaybe "" mglibdir
2013-03-04 11:21:41 +09:00
]
where
currentDir = cradleCurrentDir cradle
2013-09-19 16:21:48 +09:00
mCabalFile = cradleCabalFile cradle
rootDir = cradleRootDir cradle
2013-09-19 16:21:48 +09:00
cabal = isJust mCabalFile
cabalFile = fromMaybe "" mCabalFile
origGopts = ghcOpts opt
simpleCompilerOption = CompilerOptions origGopts [] []
fromCabalFile = do
pkgDesc <- parseCabalFile file
getCompilerOptions origGopts cradle pkgDesc
2013-09-19 16:21:48 +09:00
where
file = fromJust mCabalFile
2014-03-20 16:21:48 +09:00
----------------------------------------------------------------
-- | Obtaining root information.
rootInfo :: Options
-> Cradle
-> IO String
2014-04-21 11:22:39 +09:00
rootInfo opt cradle = return $ convert opt $ cradleRootDir cradle