From 7474968486d9b2c84d428ddf802471971f1807df Mon Sep 17 00:00:00 2001 From: Kazu Yamamoto Date: Wed, 15 Feb 2012 13:58:04 +0900 Subject: [PATCH] fixing terrible bug on Maybe. --- Cabal.hs | 8 ++++---- Gap.hs | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Cabal.hs b/Cabal.hs index 40f611c..c1e79b0 100644 --- a/Cabal.hs +++ b/Cabal.hs @@ -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) diff --git a/Gap.hs b/Gap.hs index 20ad2e6..e2e1286 100644 --- a/Gap.hs +++ b/Gap.hs @@ -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 +-} + ---------------------------------------------------------------- ----------------------------------------------------------------