Check.hs 802 B

12345678910111213141516171819202122232425262728293031
  1. module Check (checkSyntax) where
  2. import Cabal
  3. import Control.Applicative
  4. import CoreMonad
  5. import ErrMsg
  6. import Exception
  7. import GHC
  8. import GHCApi
  9. import Prelude
  10. import Types
  11. ----------------------------------------------------------------
  12. checkSyntax :: Options -> String -> IO String
  13. checkSyntax opt file = unlines <$> check opt file
  14. ----------------------------------------------------------------
  15. check :: Options -> String -> IO [String]
  16. check opt fileName = withGHC' fileName $ checkIt `gcatch` handleErrMsg
  17. where
  18. checkIt = do
  19. (file,readLog) <- initializeGHC opt fileName options True
  20. setTargetFile file
  21. _ <- load LoadAllTargets
  22. liftIO readLog
  23. options
  24. | expandSplice opt = "-w:" : ghcOpts opt
  25. | otherwise = "-Wall" : ghcOpts opt