Merge pull request #792 from atom-haskell/hlint-sporadic-spaces

Fix sporadic spaces in output on hlint parse error
This commit is contained in:
Nikolay Yakimov 2016-05-18 16:29:36 +03:00
commit b3f4677082

View File

@ -9,7 +9,7 @@ import Language.Haskell.GhcMod.Monad
import Language.Haskell.HLint3 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.SrcLoc (SrcLoc(..))
import System.IO import System.IO
-- | Checking syntax of a target file using hlint. -- | Checking syntax of a target file using hlint.
@ -27,7 +27,8 @@ lint opt file = ghandle handler $
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} ->
return $ prettyPrint loc ++ ":Error:" ++ err ++ "\n" return $ showSrcLoc loc ++ ":Error:" ++ err ++ "\n"
where where
pack = convert' . map init -- init drops the last \n. pack = convert' . map init -- init drops the last \n.
handler (SomeException e) = return $ checkErrorPrefix ++ show e ++ "\n" handler (SomeException e) = return $ checkErrorPrefix ++ show e ++ "\n"
showSrcLoc (SrcLoc f l c) = concat [f, ":", show l, ":", show c]