@@ -1,19 +1,43 @@
1+module Main where
2+
3+import Control.Monad
14import Language.Haskell.HLint3 (hlint)
5+import System.Directory
26import System.Exit (exitFailure, exitSuccess)
7+import System.FilePath.Find
8+import System.FilePath
39
410main :: IO ()
511main = do
6− ideas <- hlint
7− [ "."
8− , "--ignore=Redundant do"
9− , "--ignore=Use camelCase"
10− , "--ignore=Redundant $"
11− , "--ignore=Use &&"
12− , "--ignore=Use &&&"
13− , "--ignore=Use const"
14− , "--ignore=Use >=>"
15− , "--ignore=Use ."
16− , "--ignore=Use unless"
17− , "--cpp-define=USE_TEMPLATE_HASKELL"
18− ]
12+ pwd <- getCurrentDirectory
13+ let runHlint f = hlint $ f:
14+ [ "--ignore=Redundant do"
15+ , "--ignore=Use camelCase"
16+ , "--ignore=Redundant $"
17+ , "--ignore=Use &&"
18+ , "--ignore=Use &&&"
19+ , "--ignore=Use const"
20+ , "--ignore=Use >=>"
21+ , "--ignore=Use ."
22+ , "--ignore=Use unless"
23+ , "--cpp-define=USE_TEMPLATE_HASKELL"
24+ ]
25+ recurseInto = and <$> sequence
26+ [ fileType ==? Directory
27+ , fileName /=? ".git"
28+ ]
29+ matchFile = and <$> sequence
30+ [ extension ==? ".hs"
31+ , let notElem' = liftOp notElem
32+ in filePath `notElem'` filePathExceptions pwd
33+ ]
34+ files <- find always matchFile pwd
35+ ideas <- fmap concat $ forM files $ \f -> do
36+ putStr $ "linting file " ++ drop (length pwd + 1) f ++ "... "
37+ runHlint f
1938 if null ideas then exitSuccess else exitFailure
39+
40+filePathExceptions :: FilePath -> [FilePath]
41+filePathExceptions pwd = map (pwd </>) $
42+ [ "src/Data/AppendMap.hs" -- parse error when hlint runs
43+ ]