ghc-mod
ghc-mod copied to clipboard
ghc-mod interactive: lint problem
Hello guys,
I am facing strange problem on ghc-mod. When I ran this command with no error:
$ ghc-mod lint -h --ignore='Use list comprehension' file.hs
$ echo $?
0
But, I need to run in legacy-interactive, so:
$ ghc-mod legacy-interactive
lint -h --ignore='Use list comprehension' redo.hs
NG Invalid argument `comprehension''\n\nUsage: leandro@leandro-desktop:~/workspaces/haskell/redo-ep07$
And, I tried:
workspaces/haskell/redo-ep07$ ghc-mod legacy-interactive
lint -h [] redo.hs
redo.hs:69:41: Suggestion: Use list comprehensionFound: if hasExtension target then replaceBaseName target "default" ++ ".do"] else []Why not: [replaceBaseName target "default" ++ .do" | hasExtension target]
OK
lint -h ["-i \"Use list comprehension\""] redo.hs
NG Invalid argument `list'\n\nUsage: leandro@leandro-desktop:~/workspaces/haskeve/redo-ep07$ ghc-mod legacy-interactiv
And, I also tried from ghc-modi
leandro@leandro-desktop:~/workspaces/haskell/redo-ep07$ ghc-mod legacy-interactive
lint ["--ignore=Use camelCase", "--ignore=Eta reduce"] redo.hs
NG Invalid argument `camelCase",'\n\nUsage: leandro@leandro-desktop:~/workspaces/haskell/redo-ep07$
ghc-mod version
leandro@leandro-desktop:~/workspaces/haskell/redo-ep07$ ghc-mod --version
ghc-mod version 5.7.0.0 compiled by GHC 8.0.2
hlint version
leandro@leandro-desktop:~/workspaces/haskell/redo-ep07$ hlint -V
HLint v1.9.41, (C) Neil Mitchell 2006-2016
Is there some configuration to make?
You're venturing into some dark corners here, try this:
printf 'ascii-escape lint -h\x02--ignore=Use list comprehension\x03 Setup.hs\n\n' | ghc-mod legacy-interactive
Those two escaped ASCII control sequences are "\STX" and "\ETX" (in Haskell string syntax) respectively. Those two characters basically behave like quotes here but they don't nest. I don't recall why exactly we went for that instead of implementing normal shell escaping rules IIRC just because it was simpler.
This only appeared in v5.5.0.0 before that we didn't have a mechanism for spaces in legacy-interactive.
Thanks for reply, @DanielG .
I am using with Emacs. There is a elisp source code ghc-check.el, which implements the function
(defun ghc-check-send ()
(let ((file (buffer-file-name)))
(if ghc-check-command
(let ((opts (ghc-haskell-list-of-string ghc-hlint-options)))
(if opts
(format "lint %s %s\n" opts file)
(format "lint %s\n" file)))
(format "check %s\n" file))))
I think this function formats command for ghc-mod interactive. Is it correct?
It is entirely possible that we didn't get around to patching that into the elisp bits yet. Those changes were for Atom (ide-haskell) really. So if you want that in Emacs it should be reasonably easy to fix since you already found the right function and all. Patches welcome and what have you :)
I will try make a patch. I was checking the ground to see where I am stepping. =)
0001-Correction-on-formatted-string-for-Emacs-ghc-lint.patch.txt
I dont know if the correct way. I tried to make a pull request, but I am not allawed.
That's strange. Did you fork the repo or try to push to this one?
yeap, but I am not familiar with git.
Maybe you can quickly read through this Pull Request Tutorial?
Thanks @DanielG
#875