removing warnings.

This commit is contained in:
Kazu Yamamoto 2014-05-08 10:49:40 +09:00
parent ec5e42a5ba
commit f199ea9e2e

View File

@ -12,16 +12,13 @@ module Language.Haskell.GhcMod.CabalApi (
, cabalConfigDependencies , cabalConfigDependencies
) where ) where
#if MIN_VERSION_base(4,7,0)
import Prelude hiding (catch)
#endif
import Language.Haskell.GhcMod.Types import Language.Haskell.GhcMod.Types
import Language.Haskell.GhcMod.GhcPkg import Language.Haskell.GhcMod.GhcPkg
import Language.Haskell.GhcMod.Utils import Language.Haskell.GhcMod.Utils
import Control.Applicative ((<$>)) import Control.Applicative ((<$>))
import Control.Exception (throwIO,catch,SomeException) import Control.Exception (SomeException(..))
import qualified Control.Exception as E
import Control.Monad (filterM) import Control.Monad (filterM)
import CoreMonad (liftIO) import CoreMonad (liftIO)
import Data.Maybe (maybeToList) import Data.Maybe (maybeToList)
@ -88,9 +85,9 @@ parseCabalFile file = do
cid <- getGHCId cid <- getGHCId
epgd <- readPackageDescription silent file epgd <- readPackageDescription silent file
case toPkgDesc cid epgd of case toPkgDesc cid epgd of
Left deps -> throwIO $ userError $ show deps ++ " are not installed" Left deps -> E.throwIO $ userError $ show deps ++ " are not installed"
Right (pd,_) -> if nullPkg pd Right (pd,_) -> if nullPkg pd
then throwIO $ userError $ file ++ " is broken" then E.throwIO $ userError $ file ++ " is broken"
else return pd else return pd
where where
toPkgDesc cid = finalizePackageDescription [] (const True) buildPlatform cid [] toPkgDesc cid = finalizePackageDescription [] (const True) buildPlatform cid []
@ -166,7 +163,7 @@ getGHC :: IO Version
getGHC = do getGHC = do
mv <- programFindVersion ghcProgram silent (programName ghcProgram) mv <- programFindVersion ghcProgram silent (programName ghcProgram)
case mv of case mv of
Nothing -> throwIO $ userError "ghc not found" Nothing -> E.throwIO $ userError "ghc not found"
Just v -> return v Just v -> return v
---------------------------------------------------------------- ----------------------------------------------------------------
@ -217,9 +214,8 @@ type CabalConfig = String
-- configure@ i.e. configure with default options like @cabal build@ would do. -- configure@ i.e. configure with default options like @cabal build@ would do.
cabalGetConfig :: Cradle -> IO CabalConfig cabalGetConfig :: Cradle -> IO CabalConfig
cabalGetConfig cradle = cabalGetConfig cradle =
readFile path `catch'` (\_ -> configure >> readFile path) readFile path `E.catch` (\(SomeException _) -> configure >> readFile path)
where where
catch' = catch :: IO a -> (SomeException -> IO a) -> IO a
prjDir = cradleRootDir cradle prjDir = cradleRootDir cradle
path = prjDir </> cabalConfigPath path = prjDir </> cabalConfigPath
configure = configure =