extract initializeGHC.

This commit is contained in:
Kazu Yamamoto
2011-05-24 16:17:19 +09:00
parent ce1123395b
commit 3b6848d7a5
2 changed files with 11 additions and 21 deletions

View File

@@ -23,20 +23,9 @@ checkSyntax _ file = unlines <$> check file
check :: String -> IO [String]
check fileName = withGHC $ do
file <- initializeGHC fileName options
setTargetFile file
ref <- newRef []
(owdir,mdirfile) <- getDirs
case mdirfile of
Nothing -> do
initSession options Nothing
setTargetFile fileName
Just (cdir,cfile) -> do
midirs <- parseCabalFile cfile
changeToCabalDirectory cdir
let idirs = case midirs of
Nothing -> [cdir,owdir]
Just dirs -> dirs ++ [owdir]
initSession options (Just idirs)
setTargetFile (ajustFileName fileName owdir cdir)
loadWithLogger (refLogger ref) LoadAllTargets `gcatch` handleParseError ref
clearWarnings
readRef ref