diff --git a/Language/Haskell/GhcMod.hs b/Language/Haskell/GhcMod.hs index 9e2750b..af1c885 100644 --- a/Language/Haskell/GhcMod.hs +++ b/Language/Haskell/GhcMod.hs @@ -33,6 +33,7 @@ module Language.Haskell.GhcMod ( , typeOf , listMods , debug + , lint ) where import Language.Haskell.GhcMod.Browse diff --git a/Language/Haskell/GhcMod/Lint.hs b/Language/Haskell/GhcMod/Lint.hs index 5dcd533..8206659 100644 --- a/Language/Haskell/GhcMod/Lint.hs +++ b/Language/Haskell/GhcMod/Lint.hs @@ -14,15 +14,18 @@ import System.IO (hClose, openTempFile, stdout) lintSyntax :: Options -> FilePath -- ^ A target file. -> IO String -lintSyntax opt file = pack <$> lint opt file +lintSyntax opt file = pack <$> lint hopts file where LineSeparator lsep = lineSeparator opt 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. -> 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 f = do