I'm trying to lint a file with ghc-mod. I know ghc-mod uses hlint for this and I know that hlint accepts arguments to modify the suggestions it reports. For instance, this works just fine:
eric@linux-epth:total-beginner-haskell$ hlint src/Borrower.hs --hint=Generalise
src/Borrower.hs:44:3: Suggestion: Use mappend
Found:
getName br ++
" (" `mappend` show (getMaxBooks br) `mappend` " books)"
Why not:
getName br `Data.Monoid.mappend`
(" (" `mappend` show (getMaxBooks br) `mappend` " books)")
1 hint
Here's the format ghc-mod requires for passing arguments to hlint:
Usage: ghc-mod lint [-h|--hlintOpt ARG] FILE
But none of the variations below produce the hint shown above:
eric@linux-epth:total-beginner-haskell$ ghc-mod lint -h hint=Generalise src/Borrower.hs
eric@linux-epth:total-beginner-haskell$ ghc-mod lint --hlintOpt hint=Generalise src/Borrower.hs
eric@linux-epth:total-beginner-haskell$ ghc-mod lint --hlintOpt "--hint=Generalise" src/Borrower.hs
eric@linux-epth:total-beginner-haskell$ ghc-mod lint --hlintOpt '--hint=Generalise' src/Borrower.hs
What is the correct format to use with ghc-mod to pass arguments through it to hlint?
Thank you.
It seems that it is a bug of ghc-mod:
Issue: https://github.com/DanielG/ghc-mod/issues/826
It's already fixed and merged to master, but not yet released.
Since the issue's milestone is v5.8.0.0
, it may be fixed in that release.
I built the ghc-mod
from latest master
branch from Github, and confirmed that following command works:
$ ghc-mod lint src/Borrower.hs --hlintOpt='--hint=Generalise.hs'
src/Borrower.hs:1:8: Suggestion: Use mappendFound: getName br ++ " (" `mappend` show (getMaxBooks br) `mappend` " books)"Why not: getName br `Data.Monoid.mappend` (" (" `mappend` show (getMaxBooks br) `mappend` " books)"
Here's the step that I executed to build latest ghc-mod
from Github.
$ git clone https://github.com/DanielG/ghc-mod
$ cd ghc-mod
$ stack init --ignore-subdirs --solver
$ stack build