Defines a Flycheck checker for running the PureScript compiler through Pulp. Based on Bodil's Stokke's: https://github.com/bodil/ohai-emacs/blob/master/modules/ohai-purescript.el#L43
Supports:
- Standard compiler error messages
- psc: deprecation messages
- Syntax errors
Requires, in addition to emacs & flycheck:
- purescript
- pulp
- To be run in a project context, e.g., after
pulp init
(require 'purescript-mode)
(flycheck-define-checker
pulp
"Use Pulp to flycheck PureScript code."
:command ("pulp" "--monochrome" "build")
:error-patterns
((error line-start
(or (and "Error at " (file-name) " line " line ", column " column
(one-or-more not-newline)
(message (one-or-more (not (in "*")))))
(and "psc: " (one-or-more not-newline) "\n"
(message (one-or-more not-newline) "\n")
"at \"" (file-name) "\" (line " line ", column " column ")")
(and "Unable to parse module:\n"
" \"" (file-name) "\" (line " line ", column " column "):\n"
(message (one-or-more not-newline) "\n"
(one-or-more not-newline) "\n"
(one-or-more not-newline) "\n"))
)
line-end
))
:modes purescript-mode)
factorial :: Int -> Int
factorial num = go num 1
where go n acc
| n <= 0 = acc
| otherwise = go (wat - 1) (n * acc)
-- ^ ^
Emacs minibuffer output:
Unknown value wat
See https://github.com/purescript/purescript/wiki/Error-Code-UnknownValue for more information, or to contribute content related to this error.
map :: (a -> b) -> Array a -> Array b
map f [] = []
map f (x:xs) = f x : map f xs'
-- ^ ^
Emacs minibuffer output:
Cons binders are no longer supported. Consider using purescript-lists or purescript-sequences instead.
map :: (a -> b) -> [a] -> [b]
-- ^^
map f [] = []
map f (x:xs) = f x : map f xs'
Emacs minibuffer output:
Array notation is no longer supported. Use Array _ instead of [_].
datac Color = Red | Green | Blue
-- ^
Emacs minibuffer output:
unexpected Pipe
expecting no indentation or end of input
See https://github.com/purescript/purescript/wiki/Error-Code-ErrorParsingModule for more information, or to contribute content related to this error.
f' :: Color -> Color
f' Red = Green
-- ^
f' 1 = Blue
f' Blue = Red
Emacs minibuffer shows:
Cannot unify type
Data.Math.Color
with type
Prim.Int
See https://github.com/purescript/purescript/wiki/Error-Code-TypesDoNotUnify for more information, or to contribute content related to this error.
Compiling Data.Math
Thank you!
I had to also add this to my Spacemacs config to select the checker: