Using HLint API!.

This commit is contained in:
Kazu Yamamoto 2010-06-08 11:12:59 +09:00
parent 6e6e1c9ad7
commit 740ab2a054
4 changed files with 8 additions and 15 deletions

View File

@ -31,16 +31,12 @@ usage = "ghc-mod version 0.4.1\n"
defaultOptions :: Options
defaultOptions = Options {
convert = toPlain
, hlint = "hlint"
}
argspec :: [OptDescr (Options -> Options)]
argspec = [ Option "l" ["tolisp"]
(NoArg (\opts -> opts { convert = toLisp }))
"print as a list of Lisp"
, Option "f" ["hlint"]
(ReqArg (\str opts -> opts { hlint = str }) "hlint")
"path to hlint"
]
parseArgs :: [OptDescr (Options -> Options)] -> [String] -> (Options, [String])

16
Lint.hs
View File

@ -2,19 +2,17 @@ module Lint where
import Control.Applicative
import Data.List
import System.IO
import System.Process
import Language.Haskell.HLint
import Types
lintSyntax :: Options -> String -> IO String
lintSyntax cmd file = pretty <$> lint cmd file
lintSyntax _ file = pretty <$> lint file
where
pretty = unlines . map (concat . intersperse "\0")
. filter (\x -> length x > 1)
. groupBy (\a b -> a /= "" && b /= "")
. lines
. groupBy (\a b -> a /= "" && b /= "") . lines
lint :: Options -> String -> IO String
lint cmd file = do
(_,hout,_,_) <- runInteractiveProcess (hlint cmd) ["-i","Use camelCase",file] Nothing Nothing
hGetContents hout
lint :: String -> IO String
lint file = toString <$> hlint [file, "--quiet", "--ignore=Use camelCase"]
where
toString = concat . map show

View File

@ -6,7 +6,6 @@ import GHC.Paths (libdir)
data Options = Options {
convert :: [String] -> String
, hlint :: String
}
withGHC :: Ghc [String] -> IO [String]

View File

@ -29,7 +29,7 @@ Executable ghc-mod
else
GHC-Options: -Wall
Build-Depends: base >= 4.0 && < 5, ghc, ghc-paths,
process, directory, filepath
process, directory, filepath, hlint
Source-Repository head
Type: git
Location: git://github.com/kazu-yamamoto/ghc-mod.git