From 748c57f0c1419e48c1c73586d84979f91e53e147 Mon Sep 17 00:00:00 2001 From: HIBINO Kei Date: Mon, 14 Nov 2011 19:20:02 +0900 Subject: [PATCH] Switch when using cabal-dev case. Bugfix of cabal-dev case. --- CabalDev.hs | 8 ++++---- Check.hs | 4 +--- GHCMod.hs | 5 +++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/CabalDev.hs b/CabalDev.hs index 1e4be52..8aa202f 100644 --- a/CabalDev.hs +++ b/CabalDev.hs @@ -9,7 +9,7 @@ options ghc-mod uses to check the source. Otherwise just pass it on. import Data.Maybe (listToMaybe) import System.FilePath.Find -import System.FilePath.Posix (splitPath,joinPath) +import System.FilePath.Posix (splitPath,joinPath,()) import System.Posix.Directory (getWorkingDirectory) import System.Directory @@ -29,8 +29,8 @@ findCabalDev = addPath :: Options -> String -> Options addPath orig_opts path = do - let orig_paths = packageConfs orig_opts - orig_opts { packageConfs = orig_paths ++ [path] } + let orig_ghcopt = ghcOpts orig_opts + orig_opts { ghcOpts = orig_ghcopt ++ ["-package-conf", path] } searchIt :: [FilePath] -> IO (Maybe FilePath) searchIt [] = return Nothing @@ -42,4 +42,4 @@ searchIt path = do else return Nothing where - mpath a = joinPath a ++ "cabal-dev/" + mpath a = joinPath a "cabal-dev/" diff --git a/Check.hs b/Check.hs index 66fa9bd..4dd9cf1 100644 --- a/Check.hs +++ b/Check.hs @@ -1,7 +1,6 @@ module Check (checkSyntax) where import Cabal -import CabalDev (modifyOptions) import Control.Applicative import CoreMonad import ErrMsg @@ -14,8 +13,7 @@ import Types checkSyntax :: Options -> String -> IO String checkSyntax opt file = do - opt' <- modifyOptions opt - unlines <$> check opt' file + unlines <$> check opt file ---------------------------------------------------------------- diff --git a/GHCMod.hs b/GHCMod.hs index 2953651..567d47d 100644 --- a/GHCMod.hs +++ b/GHCMod.hs @@ -2,6 +2,7 @@ module Main where +import CabalDev (modifyOptions) import Browse import Check import Control.Applicative @@ -89,8 +90,8 @@ instance Exception GHCModError main :: IO () main = flip catches handlers $ do args <- getArgs - let (opt,cmdArg) = parseArgs argspec args - res <- case safelist cmdArg 0 of + let (opt',cmdArg) = parseArgs argspec args + res <- modifyOptions opt' >>= \opt -> case safelist cmdArg 0 of "browse" -> concat <$> mapM (browseModule opt) (tail cmdArg) "list" -> listModules opt "check" -> withFile (checkSyntax opt) (safelist cmdArg 1)