Merge branch 'fix-718' of https://github.com/atom-haskell/ghc-mod into release-5.5.0.0

This commit is contained in:
Daniel Gröber 2016-01-09 22:40:47 +01:00
commit 68cd165088
1 changed files with 8 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import Control.Applicative
import Control.Monad
import Data.Typeable (Typeable)
import Data.List
import Data.List.Split
import Exception
import Language.Haskell.GhcMod
import Language.Haskell.GhcMod.Internal hiding (MonadIO,liftIO)
@ -85,10 +86,15 @@ legacyInteractiveLoop asyncSymbolDb world = do
interactiveHandlers =
[ GHandler $ \(e :: ExitCode) -> throw e
, GHandler $ \(InvalidCommandLine e) -> do
gmErrStrLn $ either ("Invalid command line: "++) Prelude.id e
return ""
let err = notGood $ either ("Invalid command line: "++) Prelude.id e
liftIO $ do
putStr err
exitFailure
, GHandler $ \(SomeException e) -> gmErrStrLn (show e) >> return ""
]
notGood msg = "NG " ++ escapeNewlines msg
escapeNewlines = replace "\n" "\\n" . replace "\\n" "\\\\n"
replace needle replacement = intercalate replacement . splitOn needle
getFileSourceFromStdin :: IO String
getFileSourceFromStdin = do