module Language.Haskell.HLint2(
applyHints,
Idea(..), Severity(..), Note(..),
Classify(..),
getHLintDataDir,
autoSettings, findSettings, readSettings,
Hint(..), builtinHints,
HintRule(..), hintRules,
Scope, scopeCreate, scopeMatch, scopeMove,
parseModuleEx, defaultParseFlags, ParseError(..), ParseFlags(..), CppFlags(..),
Encoding, defaultEncoding, readEncoding, useEncoding
) where
import Settings
import Idea
import Apply
import Hint.Type
import Hint.All
import Util
import CmdLine
import Paths_hlint
import Control.Applicative
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Monoid
import System.FilePath
getHLintDataDir :: IO FilePath
getHLintDataDir = getDataDir
autoSettings :: IO (ParseFlags, [Classify], Hint)
autoSettings = do
dataDir <- getHLintDataDir
(builtin, matches) <- first resolveBuiltin <$> findSettings dataDir (dataDir </> "HLint.hs") Nothing
let (classify, rules) = second hintRules $ concat2 $ map readSettings matches
let fixities = getFixity =<< moduleDecls =<< matches
return (parseFlagsAddFixities fixities defaultParseFlags, classify, mconcat $ rules : builtin)
resolveBuiltin :: [String] -> [Hint]
resolveBuiltin builtin = map f $ nub $ concat [if x == "All" then map fst builtinHints else [x] | x <- builtin]
where f x = fromMaybe (error $ "Unknown builtin hints: HLint.Builtin." ++ x) $ lookup x builtinHints
_docs :: IO ()
_docs = do
(flags, classify, hint) <- autoSettings
Right m <- parseModuleEx flags "MyFile.hs" Nothing
print $ applyHints classify hint [m]