ghc-mod/Debug.hs

38 lines
1.2 KiB
Haskell
Raw Normal View History

2013-03-04 04:41:56 +00:00
module Debug (debugInfo) where
2013-03-04 02:21:41 +00:00
import CabalApi
import GHCApi
import Control.Applicative
import Data.List (intercalate)
import Data.Maybe
import Prelude
import Types
----------------------------------------------------------------
2013-03-04 09:11:09 +00:00
debugInfo :: Options -> Cradle -> String -> String -> IO String
debugInfo opt cradle ver fileName = unlines <$> debug opt cradle ver fileName
2013-03-04 02:21:41 +00:00
2013-03-04 09:11:09 +00:00
debug :: Options -> Cradle -> String -> String -> IO [String]
debug opt cradle ver fileName = do
2013-03-04 02:21:41 +00:00
(gopts, incDir, pkgs, langext) <-
if cabal then
fromCabalFile (ghcOpts opt) cradle
else
return (ghcOpts opt, [], [], [])
2013-03-04 04:41:56 +00:00
dflags <- getDynamicFlags
fast <- getFastCheck dflags fileName (Just langext)
2013-03-04 02:21:41 +00:00
return [
2013-03-04 09:11:09 +00:00
"GHC version: " ++ ver
2013-03-04 02:21:41 +00:00
, "Current directory: " ++ currentDir
, "Cabal file: " ++ cabalFile
, "GHC options: " ++ intercalate " " gopts
, "Include directories: " ++ intercalate " " incDir
, "Dependent packages: " ++ intercalate ", " pkgs
2013-03-04 04:11:04 +00:00
, "Fast check: " ++ if fast then "Yes" else "No"
2013-03-04 02:21:41 +00:00
]
where
currentDir = cradleCurrentDir cradle
cabal = isJust $ cradleCabalFile cradle
cabalFile = fromMaybe "" $ cradleCabalFile cradle