From ad1b95982030b8f0fed9be0ce4b6c39c61b869b5 Mon Sep 17 00:00:00 2001 From: Kazu Yamamoto Date: Thu, 20 Oct 2011 11:22:24 +0900 Subject: [PATCH 1/6] ver bumps up. We will break backward compatibility. --- GHCMod.hs | 2 +- elisp/ghc.el | 2 +- ghc-mod.cabal | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/GHCMod.hs b/GHCMod.hs index 9576be7..04de71e 100644 --- a/GHCMod.hs +++ b/GHCMod.hs @@ -21,7 +21,7 @@ import Types ---------------------------------------------------------------- usage :: String -usage = "ghc-mod version 0.6.2\n" +usage = "ghc-mod version 1.0.0\n" ++ "Usage:\n" ++ "\t ghc-mod list [-l]\n" ++ "\t ghc-mod lang [-l]\n" diff --git a/elisp/ghc.el b/elisp/ghc.el index 8224c2f..0d1526b 100644 --- a/elisp/ghc.el +++ b/elisp/ghc.el @@ -16,7 +16,7 @@ ;;; Code: -(defconst ghc-version "0.6.1") +(defconst ghc-version "1.0.0") ;; (eval-when-compile ;; (require 'haskell-mode)) diff --git a/ghc-mod.cabal b/ghc-mod.cabal index 0f38f53..769e8b7 100644 --- a/ghc-mod.cabal +++ b/ghc-mod.cabal @@ -1,5 +1,5 @@ Name: ghc-mod -Version: 0.6.2 +Version: 1.0.0 Author: Kazu Yamamoto Maintainer: Kazu Yamamoto License: BSD3 From b23941fafed1b83c258de7368be76b30a6274b89 Mon Sep 17 00:00:00 2001 From: Kazu Yamamoto Date: Thu, 20 Oct 2011 11:24:25 +0900 Subject: [PATCH 2/6] fixing manual. --- GHCMod.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GHCMod.hs b/GHCMod.hs index 04de71e..aba0de3 100644 --- a/GHCMod.hs +++ b/GHCMod.hs @@ -52,10 +52,10 @@ argspec = [ Option "l" ["tolisp"] "print as a list of Lisp" , Option "h" ["hlintOpt"] (ReqArg (\h opts -> opts { hlintOpts = h : hlintOpts opts }) "hlintOpt") - "hint to be ignored" + "hlint options" , Option "g" ["ghcOpt"] (ReqArg (\g opts -> opts { ghcOpts = g : ghcOpts opts }) "ghcOpt") - "extra GHC options" + "GHC options" , Option "o" ["operators"] (NoArg (\opts -> opts { operators = True })) "print operators, too" From f62f054afef28f770295c6128e729c2af036913d Mon Sep 17 00:00:00 2001 From: Craig Citro Date: Sun, 23 Oct 2011 02:01:52 -0700 Subject: [PATCH 3/6] Silly tweak to .gitignore. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 849ddff..0d2ac34 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ dist/ +elisp/*.elc From 3efbf590287a3e90ee8a59fe60d87593858d1de8 Mon Sep 17 00:00:00 2001 From: Clint Moore Date: Tue, 1 Nov 2011 15:06:53 -0700 Subject: [PATCH 4/6] 'check' command now supports cabal-dev. --- CabalDev.hs | 45 +++++++++++++++++++++++++++++++++++++++++++++ Check.hs | 7 ++++++- ghc-mod.cabal | 4 ++-- 3 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 CabalDev.hs diff --git a/CabalDev.hs b/CabalDev.hs new file mode 100644 index 0000000..79cd71f --- /dev/null +++ b/CabalDev.hs @@ -0,0 +1,45 @@ +module CabalDev (modifyOptions) where + +{- +If the directory 'cabal-dev/packages-X.X.X.conf' exists, add it to the +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.Posix.Directory (getWorkingDirectory) +import System.Directory + +import Types + +modifyOptions :: Options -> IO Options +modifyOptions opts = + fmap (has_cdev opts) findCabalDev + where + has_cdev :: Options -> Maybe String -> Options + has_cdev op Nothing = op + has_cdev op (Just path) = addPath op path + +findCabalDev :: IO (Maybe String) +findCabalDev = + getWorkingDirectory >>= searchIt . splitPath + +addPath :: Options -> String -> Options +addPath orig_opts path = do + let orig_paths = packageConfs orig_opts + orig_opts { + packageConfs = orig_paths ++ [path] } + +searchIt :: [FilePath] -> IO (Maybe FilePath) +searchIt [] = return Nothing +searchIt path = do + a <- doesDirectoryExist (mpath path) + case a of + False -> return Nothing + True -> do + b <- find always (fileName ~~? "packages*.conf") $ mpath path + maybe (searchIt $ init path) (return . Just) $ listToMaybe b + where + mpath a = (joinPath a) ++ "cabal-dev/" + diff --git a/Check.hs b/Check.hs index e34e034..ca6687e 100644 --- a/Check.hs +++ b/Check.hs @@ -9,10 +9,15 @@ import GHC import Prelude hiding (catch) import Types +import CabalDev (modifyOptions) + ---------------------------------------------------------------- checkSyntax :: Options -> String -> IO String -checkSyntax opt file = unlines <$> check opt file +--checkSyntax opt file = unlines <$> check opt file +checkSyntax opt file = do + opt' <- modifyOptions opt + unlines <$> check opt' file ---------------------------------------------------------------- diff --git a/ghc-mod.cabal b/ghc-mod.cabal index 769e8b7..cf47f3f 100644 --- a/ghc-mod.cabal +++ b/ghc-mod.cabal @@ -29,8 +29,8 @@ Executable ghc-mod else GHC-Options: -Wall Build-Depends: base >= 4.0 && < 5, ghc, ghc-paths, transformers, - process, directory, filepath, old-time, - hlint >= 1.7.1, + process, directory, filepath, old-time, unix, + hlint >= 1.7.1, filemanip, attoparsec, enumerator, attoparsec-enumerator Source-Repository head Type: git From fde88dedd1b8d000d936c713a3b5b7df66e0bedc Mon Sep 17 00:00:00 2001 From: Kazu Yamamoto Date: Wed, 2 Nov 2011 10:38:19 +0900 Subject: [PATCH 5/6] cosmetic change. --- Check.hs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Check.hs b/Check.hs index ca6687e..6807ff1 100644 --- a/Check.hs +++ b/Check.hs @@ -1,6 +1,7 @@ module Check (checkSyntax) where import Cabal +import CabalDev (modifyOptions) import Control.Applicative import CoreMonad import ErrMsg @@ -9,12 +10,9 @@ import GHC import Prelude hiding (catch) import Types -import CabalDev (modifyOptions) - ---------------------------------------------------------------- checkSyntax :: Options -> String -> IO String ---checkSyntax opt file = unlines <$> check opt file checkSyntax opt file = do opt' <- modifyOptions opt unlines <$> check opt' file From 82e7c6862f2f0c8bda19be5370043597583a93c6 Mon Sep 17 00:00:00 2001 From: Kazu Yamamoto Date: Wed, 2 Nov 2011 10:43:34 +0900 Subject: [PATCH 6/6] cosmetic change. --- CabalDev.hs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/CabalDev.hs b/CabalDev.hs index 79cd71f..1e4be52 100644 --- a/CabalDev.hs +++ b/CabalDev.hs @@ -1,7 +1,9 @@ +{-# LANGUAGE DoAndIfThenElse #-} + module CabalDev (modifyOptions) where {- -If the directory 'cabal-dev/packages-X.X.X.conf' exists, add it to the +If the directory 'cabal-dev/packages-X.X.X.conf' exists, add it to the options ghc-mod uses to check the source. Otherwise just pass it on. -} @@ -17,9 +19,9 @@ modifyOptions :: Options -> IO Options modifyOptions opts = fmap (has_cdev opts) findCabalDev where - has_cdev :: Options -> Maybe String -> Options - has_cdev op Nothing = op - has_cdev op (Just path) = addPath op path + has_cdev :: Options -> Maybe String -> Options + has_cdev op Nothing = op + has_cdev op (Just path) = addPath op path findCabalDev :: IO (Maybe String) findCabalDev = @@ -28,18 +30,16 @@ findCabalDev = addPath :: Options -> String -> Options addPath orig_opts path = do let orig_paths = packageConfs orig_opts - orig_opts { - packageConfs = orig_paths ++ [path] } + orig_opts { packageConfs = orig_paths ++ [path] } searchIt :: [FilePath] -> IO (Maybe FilePath) searchIt [] = return Nothing searchIt path = do a <- doesDirectoryExist (mpath path) - case a of - False -> return Nothing - True -> do - b <- find always (fileName ~~? "packages*.conf") $ mpath path - maybe (searchIt $ init path) (return . Just) $ listToMaybe b - where - mpath a = (joinPath a) ++ "cabal-dev/" - + if a then do + b <- find always (fileName ~~? "packages*.conf") $ mpath path + maybe (searchIt $ init path) (return . Just) $ listToMaybe b + else + return Nothing + where + mpath a = joinPath a ++ "cabal-dev/"