ghc-mod/Debug.hs

42 lines
1.3 KiB
Haskell
Raw Normal View History

2013-03-13 04:37:17 +00:00
module Debug (debugInfo, debug) where
2013-03-04 02:21:41 +00:00
import CabalApi
import Control.Applicative
2013-03-13 04:17:22 +00:00
import Control.Monad
2013-03-04 02:21:41 +00:00
import Data.List (intercalate)
import Data.Maybe
2013-03-13 04:17:22 +00:00
import GHC
import GHCApi
2013-03-04 02:21:41 +00:00
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-13 04:17:22 +00:00
(gopts, incDir, pkgs) <-
2013-03-04 02:21:41 +00:00
if cabal then
fromCabalFile (ghcOpts opt) cradle
else
2013-03-13 04:17:22 +00:00
return (ghcOpts opt, [], [])
[fast] <- withGHC fileName $ do
void $ initializeFlagsWithCradle opt cradle gopts True
setTargetFile fileName
pure . canCheckFast <$> depanal [] False
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
2013-03-05 07:57:18 +00:00
, "GHC options: " ++ unwords gopts
, "Include directories: " ++ unwords incDir
2013-03-04 02:21:41 +00:00
, "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