2013-05-17 10:00:01 +09:00
|
|
|
module Language.Haskell.GhcMod.Lint where
|
2010-05-06 15:29:55 +09:00
|
|
|
|
|
|
|
|
import Control.Applicative
|
|
|
|
|
import Data.List
|
2013-05-17 10:00:01 +09:00
|
|
|
import Language.Haskell.GhcMod.Types
|
2010-06-08 11:12:59 +09:00
|
|
|
import Language.Haskell.HLint
|
2010-05-06 15:29:55 +09:00
|
|
|
|
2013-05-20 14:28:56 +09:00
|
|
|
-- | Checking syntax of a target file using hlint.
|
|
|
|
|
-- Warnings and errors are returned.
|
|
|
|
|
lintSyntax :: Options
|
|
|
|
|
-> FilePath -- ^ A target file.
|
|
|
|
|
-> IO String
|
2013-03-12 16:19:44 +09:00
|
|
|
lintSyntax opt file = pack <$> lint opt file
|
2010-05-06 15:29:55 +09:00
|
|
|
where
|
2013-03-12 16:19:44 +09:00
|
|
|
pack = unlines . map (intercalate "\0" . lines)
|
2010-05-06 15:29:55 +09:00
|
|
|
|
2013-05-20 14:28:56 +09:00
|
|
|
lint :: Options
|
|
|
|
|
-> FilePath -- ^ A target file.
|
|
|
|
|
-> IO [String]
|
2010-06-14 11:56:35 +09:00
|
|
|
lint opt file = map show <$> hlint ([file, "--quiet"] ++ hlintOpts opt)
|