Merge branch 'lierdakil/fix-722'

This commit is contained in:
Nikolay Yakimov 2016-01-12 22:43:29 +03:00
commit 2066a198eb
1 changed files with 4 additions and 1 deletions

View File

@ -10,6 +10,7 @@ import Language.Haskell.HLint3
import Language.Haskell.GhcMod.Utils (withMappedFile)
import Language.Haskell.Exts.Pretty (prettyPrint)
import System.IO
-- | Checking syntax of a target file using hlint.
-- Warnings and errors are returned.
@ -20,7 +21,9 @@ lint :: IOish m
lint opt file = ghandle handler $
withMappedFile file $ \tempfile -> do
(flags, classify, hint) <- liftIO $ argsSettings $ optLintHlintOpts opt
res <- liftIO $ parseModuleEx flags file =<< Just `fmap` readFile tempfile
hSrc <- liftIO $ openFile tempfile ReadMode
liftIO $ hSetEncoding hSrc (encoding flags)
res <- liftIO $ parseModuleEx flags file =<< Just `fmap` hGetContents hSrc
case res of
Right m -> pack . map show $ applyHints classify hint [m]
Left ParseError{parseErrorLocation=loc, parseErrorMessage=err} ->