exporting lint.

This commit is contained in:
Kazu Yamamoto 2014-03-27 10:34:30 +09:00
parent d7869c76ac
commit 4ad1c5e276
2 changed files with 7 additions and 3 deletions

View File

@ -33,6 +33,7 @@ module Language.Haskell.GhcMod (
, typeOf , typeOf
, listMods , listMods
, debug , debug
, lint
) where ) where
import Language.Haskell.GhcMod.Browse import Language.Haskell.GhcMod.Browse

View File

@ -14,15 +14,18 @@ import System.IO (hClose, openTempFile, stdout)
lintSyntax :: Options lintSyntax :: Options
-> FilePath -- ^ A target file. -> FilePath -- ^ A target file.
-> IO String -> IO String
lintSyntax opt file = pack <$> lint opt file lintSyntax opt file = pack <$> lint hopts file
where where
LineSeparator lsep = lineSeparator opt LineSeparator lsep = lineSeparator opt
pack = unlines . map (intercalate lsep . lines) pack = unlines . map (intercalate lsep . lines)
hopts = hlintOpts opt
lint :: Options -- | Checking syntax of a target file using hlint.
-- Warnings and errors are returned.
lint :: [String]
-> FilePath -- ^ A target file. -> FilePath -- ^ A target file.
-> IO [String] -> IO [String]
lint opt file = map show <$> suppressStdout (hlint ([file] ++ hlintOpts opt)) lint hopts file = map show <$> suppressStdout (hlint (file : hopts))
suppressStdout :: IO a -> IO a suppressStdout :: IO a -> IO a
suppressStdout f = do suppressStdout f = do