fixing terrible bug on Maybe.

This commit is contained in:
Kazu Yamamoto 2012-02-15 13:58:04 +09:00
parent dced95031a
commit 7474968486
2 changed files with 12 additions and 4 deletions

View File

@ -34,7 +34,7 @@ initializeGHC opt fileName ghcOptions logging =
return (fileName,logReader)
withCabal = do
(owdir,cdir,cfile) <- liftIO getDirs
binfo <- parseCabalFile cfile
binfo <- liftIO $ parseCabalFile cfile
let (idirs',exts',mlang) = extractBuildInfo binfo
exts = map addX exts'
lang = maybe "-XHaskell98" addX mlang
@ -51,10 +51,10 @@ initializeGHC opt fileName ghcOptions logging =
----------------------------------------------------------------
-- Causes error, catched in the upper function.
parseCabalFile :: FilePath -> Ghc BuildInfo
parseCabalFile :: FilePath -> IO BuildInfo
parseCabalFile file = do
cabal <- liftIO $ readPackageDescription silent file
return . fromJust $ fromLibrary cabal >> fromExecutable cabal
cabal <- readPackageDescription silent file
return . fromJust $ fromLibrary cabal <|> fromExecutable cabal
where
fromLibrary c = libBuildInfo . condTreeData <$> condLibrary c
fromExecutable c = buildInfo . condTreeData . snd <$> toMaybe (condExecutables c)

8
Gap.hs
View File

@ -31,6 +31,14 @@ import HscTypes (liftIO)
import Pretty
#endif
{-
pretty :: Outputable a => a -> String
pretty = showSDocForUser neverQualify . ppr
debug :: Outputable a => a -> b -> b
debug x v = trace (pretty x) v
-}
----------------------------------------------------------------
----------------------------------------------------------------