Set file encoding to uft8 in Lint

Fixes #722
This commit is contained in:
Nikolay Yakimov 2016-01-12 21:33:20 +03:00
parent 363aa10fcd
commit 0a0cd8041e

View File

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