Skip to content
This repository has been archived by the owner on Apr 25, 2020. It is now read-only.

ghc-mod interactive: lint problem #874

Open
lemoce opened this issue Mar 1, 2017 · 9 comments
Open

ghc-mod interactive: lint problem #874

lemoce opened this issue Mar 1, 2017 · 9 comments

Comments

@lemoce
Copy link

lemoce commented Mar 1, 2017

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?

@lemoce lemoce changed the title ghc-mod interactive: No ghc-mod interactive: lint problem Mar 1, 2017
@DanielG
Copy link
Owner

DanielG commented Mar 2, 2017

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.

@lemoce
Copy link
Author

lemoce commented Mar 2, 2017

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?

@DanielG
Copy link
Owner

DanielG commented Mar 2, 2017

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 :)

@lemoce
Copy link
Author

lemoce commented Mar 2, 2017

I will try make a patch. I was checking the ground to see where I am stepping. =)

@lemoce
Copy link
Author

lemoce commented Mar 2, 2017

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.

@DanielG
Copy link
Owner

DanielG commented Mar 2, 2017

That's strange. Did you fork the repo or try to push to this one?

@DanielG DanielG closed this as completed Mar 2, 2017
@DanielG DanielG reopened this Mar 2, 2017
@lemoce
Copy link
Author

lemoce commented Mar 2, 2017

yeap, but I am not familiar with git.

@DanielG
Copy link
Owner

DanielG commented Mar 2, 2017

Maybe you can quickly read through this Pull Request Tutorial?

@lemoce
Copy link
Author

lemoce commented Mar 2, 2017

Thanks @DanielG

#875

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants