2017-02-13 69 views
1

我正在试图用ghc-mod来绑定一个文件。我知道ghc-mod为此使用hlint,我知道hlint接受参数来修改它报告的建议。例如,这工作得很好:将hlint参数传递给ghc-mod的正确方法?

[email protected]: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 

这里的格式GHC-MOD需要将参数传递给hlint:

Usage: ghc-mod lint [-h|--hlintOpt ARG] FILE 

但是下面没有变化的产生上图所示的提示:

[email protected]:total-beginner-haskell$ ghc-mod lint -h hint=Generalise src/Borrower.hs 
[email protected]:total-beginner-haskell$ ghc-mod lint --hlintOpt hint=Generalise src/Borrower.hs 
[email protected]:total-beginner-haskell$ ghc-mod lint --hlintOpt "--hint=Generalise" src/Borrower.hs 
[email protected]:total-beginner-haskell$ ghc-mod lint --hlintOpt '--hint=Generalise' src/Borrower.hs 

ghc-mod使用正确的格式将参数传递给hlint的格式是什么?

谢谢。

回答

1

这似乎是GHC-MOD的错误:

问题:https://github.com/DanielG/ghc-mod/issues/826

它已经固定,并合并掌握,但尚未发布。

由于该问题的里程碑是v5.8.0.0,因此可能会在该版本中进行修复。

我建立了ghc-mod从最新master分支从GitHub,并确认以下命令作品:

$ 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)" 

下面是我执行从GitHub打造最新ghc-mod步骤。

$ git clone https://github.com/DanielG/ghc-mod 
$ cd ghc-mod 
$ stack init --ignore-subdirs --solver 
$ stack build 
+0

感谢您的帮助。我用“堆栈安装ghc-mod”来获得ghc mod。我有:“由GHC 8.0.1编译的ghc-mod版本5.6.0.0”。你能告诉我如何像Github的大师一样建立吗?谢谢。 – ericky

+1

@ericky我更新了答案并添加了如何构建 – ymonad

+0

非常感谢!最后一个问题:它是否会影响我将repo克隆到哪个目录? – ericky