ghc-mod/Check.hs
2012-08-06 09:43:47 +09:00

31 lines
811 B
Haskell

module Check (checkSyntax) where
import Cabal
import Control.Applicative
import CoreMonad
import ErrMsg
import Exception
import GHC
import GHCApi
import Prelude hiding (catch)
import Types
----------------------------------------------------------------
checkSyntax :: Options -> String -> IO String
checkSyntax opt file = unlines <$> check opt file
----------------------------------------------------------------
check :: Options -> String -> IO [String]
check opt fileName = withGHC $ checkIt `gcatch` handleErrMsg
where
checkIt = do
(file,readLog) <- initializeGHC opt fileName options True
setTargetFile file
_ <- load LoadAllTargets
liftIO readLog
options
| expandSplice opt = ["-w:"] ++ ghcOpts opt
| otherwise = ["-Wall"] ++ ghcOpts opt