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

43 lines
1.5 KiB
Haskell
Raw Normal View History

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