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 ((<$>))
|
2013-03-04 11:21:41 +09:00
|
|
|
import Data.List (intercalate)
|
2014-07-11 03:10:37 +02:00
|
|
|
import Data.Maybe (isJust, fromJust)
|
2014-05-12 00:40:00 +02:00
|
|
|
import Language.Haskell.GhcMod.Convert
|
2014-07-11 03:10:37 +02:00
|
|
|
import Language.Haskell.GhcMod.Monad
|
2013-05-17 10:00:01 +09:00
|
|
|
import Language.Haskell.GhcMod.Types
|
2014-07-12 03:30:06 +02:00
|
|
|
import Language.Haskell.GhcMod.Internal
|
2013-03-04 11:21:41 +09:00
|
|
|
|
|
|
|
|
----------------------------------------------------------------
|
|
|
|
|
|
2013-05-20 14:28:56 +09:00
|
|
|
-- | Obtaining debug information.
|
2014-07-12 11:16:16 +02:00
|
|
|
debugInfo :: IOish m => GhcModT m String
|
2014-07-11 03:10:37 +02:00
|
|
|
debugInfo = cradle >>= \c -> convert' =<< do
|
2013-09-19 15:58:50 +09:00
|
|
|
CompilerOptions gopts incDir pkgs <-
|
2014-07-11 03:10:37 +02:00
|
|
|
if isJust $ cradleCabalFile c then
|
2014-07-17 17:16:44 +09:00
|
|
|
fromCabalFile c ||> simpleCompilerOption
|
2013-03-04 11:21:41 +09:00
|
|
|
else
|
2014-07-11 03:10:37 +02:00
|
|
|
simpleCompilerOption
|
2013-03-04 11:21:41 +09:00
|
|
|
return [
|
2014-07-11 03:10:37 +02:00
|
|
|
"Root directory: " ++ cradleRootDir c
|
|
|
|
|
, "Current directory: " ++ cradleCurrentDir c
|
|
|
|
|
, "Cabal file: " ++ show (cradleCabalFile c)
|
2013-03-05 16:57:18 +09:00
|
|
|
, "GHC options: " ++ unwords gopts
|
|
|
|
|
, "Include directories: " ++ unwords incDir
|
2014-04-17 23:40:11 +02:00
|
|
|
, "Dependent packages: " ++ intercalate ", " (map showPkg pkgs)
|
2014-07-12 03:30:06 +02:00
|
|
|
, "System libraries: " ++ ghcLibDir
|
2013-03-04 11:21:41 +09:00
|
|
|
]
|
|
|
|
|
where
|
2014-07-11 03:10:37 +02:00
|
|
|
simpleCompilerOption = options >>= \op ->
|
2014-08-13 18:40:01 +02:00
|
|
|
return $ CompilerOptions (ghcUserOptions op) [] []
|
2014-08-12 18:11:32 +02:00
|
|
|
fromCabalFile c = options >>= \opts -> do
|
2014-09-10 22:23:36 +10:00
|
|
|
pkgDesc <- parseCabalFile c $ fromJust $ cradleCabalFile c
|
2014-08-18 08:06:36 +02:00
|
|
|
getCompilerOptions (ghcUserOptions opts) c pkgDesc
|
2014-03-20 16:21:48 +09:00
|
|
|
|
|
|
|
|
----------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
-- | Obtaining root information.
|
2014-07-12 11:16:16 +02:00
|
|
|
rootInfo :: IOish m => GhcModT m String
|
2014-07-11 03:10:37 +02:00
|
|
|
rootInfo = convert' =<< cradleRootDir <$> cradle
|