Created
March 16, 2015 22:56
-
-
Save rpglover64/a483cf6fd10380b47276 to your computer and use it in GitHub Desktop.
Work in progress on using ghc-mod for flycheck.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(flycheck-define-checker haskell-ghc-mod | |
"A Haskell syntax and type checker using ghc-mod." | |
:command ("ghc-mod" "check" source) | |
:error-patterns | |
((warning line-start (file-name) ":" line ":" column ":" | |
"Warning:" (zero-or-more space) | |
(message (one-or-more not-newline)) | |
line-end) | |
(error line-start (file-name) ":" line ":" column ":" | |
(zero-or-more space) | |
(message (one-or-more not-newline)) | |
line-end)) | |
:error-filter | |
(lambda (errors) | |
;; The commented line below should be the same as the uncommented code below, but doesn't rely on dash. | |
;; (flycheck-sanitize-errors (flycheck-dedent-error-messages (flycheck-replace-nulls errors)))) | |
(-> errors | |
flycheck-replace-nulls | |
flycheck-dedent-error-messages | |
flycheck-sanitize-errors | |
)) | |
:modes (haskell-mode literate-haskell-mode) | |
) | |
;; Not ready, but kept around for reference. | |
;; (flycheck-define-generic-checker 'haskell-ghc-modi | |
;; "A Haskell syntax and type checker using ghc-mod." | |
;; :start flycheck-haskell-ghc-modi-start | |
;; :error-patterns | |
;; ((warning line-start (file-name) ":" line ":" column ":" | |
;; "Warning:" (zero-or-more space) | |
;; (message (one-or-more not-newline)) | |
;; line-end) | |
;; (error line-start (file-name) ":" line ":" column ":" | |
;; (zero-or-more space) | |
;; (message (one-or-more not-newline)) | |
;; line-end)) | |
;; :error-filter | |
;; (lambda (errors) | |
;; ;; (flycheck-sanitize-errors (flycheck-dedent-error-messages (flycheck-replace-nulls errors)))) | |
;; (-> errors | |
;; flycheck-replace-nulls | |
;; flycheck-dedent-error-messages | |
;; flycheck-sanitize-errors | |
;; )) | |
;; :modes (haskell-mode literate-haskell-mode) | |
;; ) | |
;; (defun flycheck-haskell-ghc-modi-start (checker callback) | |
;; (setq lexical-binding t) | |
;; (let ((buffer (current-buffer))) | |
;; ;; send command to ghc process with callback | |
;; )) | |
(defun flycheck-replace-nulls (errors) | |
(dolist (err errors) | |
(let ((msg (flycheck-error-message err))) | |
(setq msg (replace-regexp-in-string "\x0" "\n" msg)) | |
(setf (flycheck-error-message err) msg))) | |
errors) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment