【问题标题】:Proper Way To Pass hlint Arguments to ghc-mod?将 hlint 参数传递给 ghc-mod 的正确方法?
【发布时间】:2017-07-01 00:12:20
【问题描述】:

我正在尝试使用 ghc-mod 对文件进行 lint。我知道 ghc-mod 为此使用 hlint,并且我知道 hlint 接受参数来修改它报告的建议。例如,这很好用:

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

这是 ghc-mod 将参数传递给 hlint 所需的格式:

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

但是下面的所有变体都不会产生上面显示的提示:

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

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

谢谢。

【问题讨论】:

    标签: haskell ghc-mod hlint


    【解决方案1】:

    好像是ghc-mod的bug:

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

    它已经修复并合并到master,但尚未发布。

    由于问题的里程碑是v5.8.0.0,它可能会在该版本中得到修复。

    我从 Github 的最新 master 分支构建了 ghc-mod,并确认以下命令有效:

    $ 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
    

    【讨论】:

    • 感谢您的帮助。我使用“stack install ghc-mod”来获取 ghc mod。我有:“由 GHC 8.0.1 编译的 ghc-mod 版本 5.6.0.0”。你能告诉我如何像你一样从 Github master 构建吗?谢谢。
    • 太好了 - 谢谢!最后一个问题:我将 repo 克隆到哪个目录有影响吗?
    • @ericky 我认为不是
    猜你喜欢
    • 2020-07-07
    • 1970-01-01
    • 1970-01-01
    • 2019-09-02
    • 2016-03-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多