pretty print for extra info.

This commit is contained in:
Kazu Yamamoto 2010-06-14 14:42:17 +09:00
parent d5763f70dc
commit 91859329ae
2 changed files with 10 additions and 6 deletions

View File

@ -6,7 +6,7 @@ import Control.Applicative
import Control.Exception hiding (try) import Control.Exception hiding (try)
import Lang import Lang
import Lint import Lint
import Data.List import List
import Prelude hiding (catch) import Prelude hiding (catch)
import System.Console.GetOpt import System.Console.GetOpt
import System.Directory import System.Directory
@ -52,7 +52,7 @@ parseArgs spec argv
---------------------------------------------------------------- ----------------------------------------------------------------
main :: IO () main :: IO ()
main = flip catch handler $ do main = flip catches handlers $ do
args <- getArgs args <- getArgs
let (opt,cmdArg) = parseArgs argspec args let (opt,cmdArg) = parseArgs argspec args
res <- case head cmdArg of res <- case head cmdArg of
@ -69,13 +69,14 @@ main = flip catch handler $ do
_ -> error usage _ -> error usage
putStr res putStr res
where where
handlers = [handler]
handler :: ErrorCall -> IO () handler :: ErrorCall -> IO ()
handler _ = putStr usage handler _ = putStr usage
withFile cmd file = do withFile cmd file = do
exist <- doesFileExist file exist <- doesFileExist file
if exist if exist
then cmd file then cmd file
else return "" else error $ file ++ " not found"
---------------------------------------------------------------- ----------------------------------------------------------------
toLisp :: [String] -> String toLisp :: [String] -> String

View File

@ -69,11 +69,14 @@
(defun ghc-flymake-insert-errors (title errs) (defun ghc-flymake-insert-errors (title errs)
(save-excursion (save-excursion
(insert title "\n") (insert title "\n\n")
(mapc (lambda (x) (insert (ghc-replace-character x ghc-null ghc-newline) "\n")) errs) (mapc (lambda (x) (insert (ghc-replace-character x ghc-null ghc-newline) "\n")) errs)
(goto-char (point-min)) (goto-char (point-min))
(while (re-search-forward "In the [^:\n]+: " nil t) (while (re-search-forward "In the [^:\n]+: \\|Expected type: \\|Inferred type: " nil t)
(replace-match (concat "\n" (match-string 0) "\n "))))) (replace-match (concat "\n" (match-string 0) "\n ")))
(goto-char (point-max))
(while (re-search-backward "In the [a-z]+ argument" nil t)
(insert "\n"))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;