From 66c8915ebdb358f39116a7c3222494182dcef31f Mon Sep 17 00:00:00 2001 From: Nikolay Yakimov Date: Mon, 16 May 2016 11:41:48 +0300 Subject: [PATCH] Fix sporadic spaces in output on hlint parse error For some reason, haskell-src-exts now adds space before ints when pretty-printing source location (probably an issue with Text.PrettyPrint) This patch avoids using pretty printer altogether. --- Language/Haskell/GhcMod/Lint.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Language/Haskell/GhcMod/Lint.hs b/Language/Haskell/GhcMod/Lint.hs index f6c549f..a506565 100644 --- a/Language/Haskell/GhcMod/Lint.hs +++ b/Language/Haskell/GhcMod/Lint.hs @@ -9,7 +9,7 @@ import Language.Haskell.GhcMod.Monad import Language.Haskell.HLint3 import Language.Haskell.GhcMod.Utils (withMappedFile) -import Language.Haskell.Exts.Pretty (prettyPrint) +import Language.Haskell.Exts.SrcLoc (SrcLoc(..)) import System.IO -- | Checking syntax of a target file using hlint. @@ -27,7 +27,8 @@ lint opt file = ghandle handler $ case res of Right m -> pack . map show $ applyHints classify hint [m] Left ParseError{parseErrorLocation=loc, parseErrorMessage=err} -> - return $ prettyPrint loc ++ ":Error:" ++ err ++ "\n" + return $ showSrcLoc loc ++ ":Error:" ++ err ++ "\n" where pack = convert' . map init -- init drops the last \n. handler (SomeException e) = return $ checkErrorPrefix ++ show e ++ "\n" + showSrcLoc (SrcLoc f l c) = concat [f, ":", show l, ":", show c]