Commit 398b38c4 authored by Steve Purcell's avatar Steve Purcell Committed by Sebastian Wiesner

Add Haskell checkers

Add syntax checkers using hdevtools, ghc and hlint.  The former two
perform syntax checking and are chained to hlint which provides style
checking.
parent 1a5f3ce6
......@@ -14,6 +14,7 @@
;; Various modes for use in the unit tests
(depends-on "coffee-mode")
(depends-on "haml-mode")
(depends-on "haskell-mode")
(depends-on "web-mode")
(depends-on "js2-mode")
(depends-on "js3-mode")
......
......@@ -36,6 +36,7 @@ Features
- Erlang
- Go
- Haml
- Haskell
- HTML
- Javascript
- JSON
......
......@@ -14,6 +14,9 @@ order of their appearance in the default value of
@iflyc go-build
@iflyc go-test
@iflyc haml
@iflyc haskell-hdevtools
@iflyc haskell-ghc
@iflyc haskell-hlint
@iflyc html-tidy
@iflyc javascript-jshint
@iflyc json-jsonlint
......
......@@ -66,6 +66,8 @@ Go (using @command{gofmt}, @command{go build} and @command{go test})
@item
Haml
@item
Haskell (using @command{ghc}, @command{hdevtools} and @command{hlint})
@item
HTML (using @command{tidy})
@item
Javascript (using @command{jshint})
......
......@@ -117,6 +117,9 @@ buffer-local wherever it is set."
go-build
go-test
haml
haskell-hdevtools
haskell-ghc
haskell-hlint
html-tidy
javascript-jshint
json-jsonlint
......@@ -2881,6 +2884,39 @@ See URL `http://haml.info'."
'(("^Syntax error on line \\(?2:[0-9]+\\): \\(?4:.*\\)$" error))
:modes 'haml-mode)
(flycheck-declare-checker haskell-hdevtools
"A Haskell syntax and type checker using hdevtools.
See URL `https://github.com/bitc/hdevtools'."
:command '("hdevtools" "check" "-g" "-Wall" source-inplace)
:error-patterns
'(("^\\(?1:.*?\\):\\(?2:[0-9]+\\):\\(?3:[0-9]+\\): Warning:\n? +\\(?4:\\(?:.+\\)\\(?:\n +.+\\)*\\)" warning)
("^\\(?1:.*\\):\\(?2:[0-9]+\\):\\(?3:[0-9]+\\):\n\\(?4:\\( +.+\n\\)*\\)" error)
("^\\(?1:.*\\):\\(?2:[0-9]+\\):\\(?3:[0-9]+\\):\\(?4:.*\\)" error))
:modes 'haskell-mode
:next-checkers '((warnings-only . haskell-hlint)))
(flycheck-declare-checker haskell-ghc
"A Haskell syntax and type checker using ghc.
See URL `http://www.haskell.org/ghc/'."
:command '("ghc" "-Wall" "-fno-code" source-inplace)
:error-patterns
'(("^\\(?1:.*?\\):\\(?2:[0-9]+\\):\\(?3:[0-9]+\\):\\(?: \\|\n \\)Warning:\n? +\\(?4:\\(?:.+\\)\\(?:\n +.+\\)*\\)" warning)
("^\\(?1:.*?\\):\\(?2:[0-9]+\\):\\(?3:[0-9]+\\):\n +\\(?4:\\(?:.+\\)\\(?:\n +.+\\)*\\)" error))
:modes 'haskell-mode
:next-checkers '((warnings-only . haskell-hlint)))
(flycheck-declare-checker haskell-hlint
"A Haskell style checker using hlint.
See URL `http://community.haskell.org/~ndm/hlint/'."
:command '("hlint" source-inplace)
:error-patterns
'(("^\\(?1:.*?\\):\\(?2:[0-9]+\\):\\(?3:[0-9]+\\): Warning: \\(?4:.+\\(?:\n.+\\)+\\)" warning)
("^\\(?1:.*?\\):\\(?2:[0-9]+\\):\\(?3:[0-9]+\\): Error: \\(?4:.+\\(?:\n.+\\)+\\)" error))
:modes 'haskell-mode)
(flycheck-def-config-file-var flycheck-tidyrc html-tidy ".tidyrc")
(flycheck-declare-checker html-tidy
......
......@@ -137,6 +137,7 @@
elixir-mode
go-mode
haml-mode
haskell-mode
web-mode
js2-mode
js3-mode
......@@ -2167,6 +2168,48 @@ See URL `https://github.com/lunaryorn/flycheck/issues/45' and URL
"checkers/haml-error.haml" 'haml-mode nil
'(5 nil "Inconsistent indentation: 3 spaces used for indentation, but the rest of the document was indented using 2 spaces." error :filename nil)))
(ert-deftest checker-haskell-hdevtools-error ()
:expected-result (flycheck-testsuite-fail-unless-checker 'haskell-hdevtools)
(flycheck-testsuite-should-syntax-check
"checkers/haskell-hdevtools-error.hs" 'haskell-mode nil
'(1 8 "Not in scope: `unknown'" error
:checker haskell-hdevtools)))
(ert-deftest checker-haskell-hdevtools-warning ()
:expected-result (flycheck-testsuite-fail-unless-checker 'haskell-hdevtools)
(flycheck-testsuite-should-syntax-check
"checkers/haskell-hdevtools-warning.hs" 'haskell-mode nil
'(3 1 "Top-level binding with no type signature: foo :: Integer" warning
:checker haskell-hdevtools)))
(ert-deftest checker-haskell-ghc-error ()
:expected-result (flycheck-testsuite-fail-unless-checker 'haskell-ghc)
(flycheck-testsuite-should-syntax-check
"checkers/haskell-ghc-error.hs" 'haskell-mode 'haskell-hdevtools
'(3 1 "parse error on input `module'" error
:checker haskell-ghc)))
(ert-deftest checker-haskell-ghc-warning ()
:expected-result (flycheck-testsuite-fail-unless-checker 'haskell-ghc)
(flycheck-testsuite-should-syntax-check
"checkers/haskell-ghc-warning.hs" 'haskell-mode 'haskell-hdevtools
'(3 1 "Top-level binding with no type signature: foo :: Integer" warning
:checker haskell-ghc)))
(ert-deftest checker-haskell-hlint-error ()
:expected-result (flycheck-testsuite-fail-unless-checker 'haskell-hlint)
(flycheck-testsuite-should-syntax-check
"checkers/haskell-hlint-error.hs" 'haskell-mode nil
'(4 1 "Eta reduce\nFound:\n warnMe xs = map lines xs\nWhy not:\n warnMe = map lines" error
:checker haskell-hlint)))
(ert-deftest checker-haskell-hlint-warning ()
:expected-result (flycheck-testsuite-fail-unless-checker 'haskell-hlint)
(flycheck-testsuite-should-syntax-check
"checkers/haskell-hlint-warning.hs" 'haskell-mode nil
'(2 8 "Redundant bracket\nFound:\n (putStrLn \"Foobar\")\nWhy not:\n putStrLn \"Foobar\"" warning
:checker haskell-hlint)))
(ert-deftest checker-html-tidy-warning-and-error ()
"Test an error caused by an unknown tag."
:expected-result (flycheck-testsuite-fail-unless-checker 'html-tidy)
......
module Foo where
foo = 10 :: Integer
module Foo
where
warnMe :: [String] -> [[String]]
warnMe xs = map lines xs
main :: IO ()
main = (putStrLn "Foobar")
......@@ -110,7 +110,10 @@ apt npm \
apt bash \
chktex \
esl-erlang \
ghc \
golang-stable \
hdevtools \
hlint \
lacheck \
lua5.2 \
php5-cli \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment