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
|
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-05-27 20:43:52 +00:00
|
|
|
checkSyntax opt file = 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]
|
|
|
|
check opt fileName = withGHC $ do
|
2011-08-24 06:58:12 +00:00
|
|
|
(file,readLog) <- initializeGHC opt fileName options True
|
2011-05-24 07:17:19 +00:00
|
|
|
setTargetFile file
|
2011-08-24 06:58:12 +00:00
|
|
|
load LoadAllTargets -- `gcatch` handleParseError ref xxx
|
|
|
|
liftIO readLog
|
2010-03-11 10:03:17 +00:00
|
|
|
where
|
2011-08-24 06:58:12 +00:00
|
|
|
options = ["-Wall","-fno-warn-unused-do-bind"] ++ map ("-i" ++) (checkIncludes opt)
|
|
|
|
{-
|
2010-05-04 10:31:14 +00:00
|
|
|
handleParseError ref e = do
|
|
|
|
liftIO . writeIORef ref $ errBagToStrList . srcErrorMessages $ e
|
|
|
|
return Succeeded
|
2011-08-24 06:58:12 +00:00
|
|
|
-}
|