ghc-mod/Language/Haskell/GhcMod/Lint.hs
2014-04-19 08:36:35 +09:00

25 lines
777 B
Haskell

module Language.Haskell.GhcMod.Lint where
import Control.Applicative ((<$>))
import Data.List (intercalate)
import Language.Haskell.GhcMod.Types
import Language.Haskell.HLint (hlint)
-- | Checking syntax of a target file using hlint.
-- Warnings and errors are returned.
lintSyntax :: Options
-> FilePath -- ^ A target file.
-> IO String
lintSyntax opt file = pack <$> lint hopts file
where
LineSeparator lsep = lineSeparator opt
pack = convert opt . map (intercalate lsep . lines)
hopts = hlintOpts opt
-- | Checking syntax of a target file using hlint.
-- Warnings and errors are returned.
lint :: [String]
-> FilePath -- ^ A target file.
-> IO [String]
lint hopts file = map show <$> hlint (file : "--quiet" : hopts)