2010-03-11 10:03:17 +00:00
|
|
|
module Check (checkSyntax) where
|
|
|
|
|
2011-05-24 07:00:47 +00:00
|
|
|
import Cabal
|
2010-03-11 10:03:17 +00:00
|
|
|
import Control.Applicative
|
2011-08-24 06:58:12 +00:00
|
|
|
import CoreMonad
|
2011-08-24 07:50:26 +00:00
|
|
|
import ErrMsg
|
|
|
|
import Exception
|
2010-04-28 12:43:32 +00:00
|
|
|
import GHC
|
2011-05-24 07:00:47 +00:00
|
|
|
import Prelude hiding (catch)
|
2010-04-30 09:36:31 +00:00
|
|
|
import Types
|
2010-03-11 10:03:17 +00:00
|
|
|
|
|
|
|
----------------------------------------------------------------
|
|
|
|
|
2010-03-11 13:39:07 +00:00
|
|
|
checkSyntax :: Options -> String -> IO String
|
2011-11-01 22:06:53 +00:00
|
|
|
checkSyntax opt file = do
|
2011-11-14 10:20:02 +00:00
|
|
|
unlines <$> check opt file
|
2010-04-28 12:43:32 +00:00
|
|
|
|
|
|
|
----------------------------------------------------------------
|
|
|
|
|
2011-05-27 20:43:52 +00:00
|
|
|
check :: Options -> String -> IO [String]
|
2011-08-24 07:50:26 +00:00
|
|
|
check opt fileName = withGHC $ checkIt `gcatch` handleErrMsg
|
2010-03-11 10:03:17 +00:00
|
|
|
where
|
2011-08-24 07:50:26 +00:00
|
|
|
checkIt = do
|
|
|
|
(file,readLog) <- initializeGHC opt fileName options True
|
|
|
|
setTargetFile file
|
|
|
|
load LoadAllTargets
|
|
|
|
liftIO readLog
|
2011-10-19 10:09:36 +00:00
|
|
|
options = ["-Wall","-fno-warn-unused-do-bind"] ++ ghcOpts opt
|